Skip to content

Commit

Permalink
primefaces#11506 lazyModel.load() can optionally set the rowCount
Browse files Browse the repository at this point in the history
  • Loading branch information
vrossellotravelc committed May 5, 2024
1 parent 7a60525 commit ffa4d6a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,13 @@ public void loadLazyData() {
calculateFirst();
}
List<?> data = lazyModel.load(getFirst(), getRows(), Collections.emptyMap(), Collections.emptyMap());
if (data.size() < getRows() && getFirst() == 0) {
lazyModel.setRowCount(data.size());
}
else if (getFirst() == 0) {
lazyModel.setRowCount(lazyModel.count(Collections.emptyMap()));
if (lazyModel.getRowCount() == 0) {
if (data.size() < getRows() && getFirst() == 0) {
lazyModel.setRowCount(data.size());
}
else if (getFirst() == 0) {
lazyModel.setRowCount(lazyModel.count(Collections.emptyMap()));
}
}

lazyModel.setPageSize(getRows());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,13 @@ public void loadLazyData() {
}

List<?> data = lazyModel.load(getFirst(), getRows(), Collections.emptyMap(), Collections.emptyMap());
if (data.size() < getRows() && getFirst() == 0) {
lazyModel.setRowCount(data.size());
}
else if (getFirst() == 0) {
lazyModel.setRowCount(lazyModel.count(Collections.emptyMap()));
if (lazyModel.getRowCount() == 0) {
if (data.size() < getRows() && getFirst() == 0) {
lazyModel.setRowCount(data.size());
}
else if (getFirst() == 0) {
lazyModel.setRowCount(lazyModel.count(Collections.emptyMap()));
}
}

lazyModel.setPageSize(getRows());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,11 +508,13 @@ public void loadLazyScrollData(int offset, int rows) {
}

List<?> data = model.load(offset, rows, getActiveSortMeta(), getActiveFilterMeta());
if (data.size() < getRows() && getFirst() == 0) {
model.setRowCount(data.size());
}
else if (getFirst() == 0) {
model.setRowCount(model.count(filterBy));
if (model.getRowCount() == 0) {
if (data.size() < getRows() && getFirst() == 0) {
model.setRowCount(data.size());
}
else if (getFirst() == 0) {
model.setRowCount(model.count(filterBy));
}
}
model.setPageSize(rows);
// set empty list if model returns null; this avoids multiple calls while visiting the component+rows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,13 @@ public void loadLazyData() {
}

List<?> data = lazyModel.load(getFirst(), getRows(), Collections.emptyMap(), Collections.emptyMap());
if (data.size() < getRows() && getFirst() == 0) {
lazyModel.setRowCount(data.size());
}
else if (getFirst() == 0) {
lazyModel.setRowCount(lazyModel.count(Collections.emptyMap()));
if (lazyModel.getRowCount() == 0) {
if (data.size() < getRows() && getFirst() == 0) {
lazyModel.setRowCount(data.size());
}
else if (getFirst() == 0) {
lazyModel.setRowCount(lazyModel.count(Collections.emptyMap()));
}
}

lazyModel.setPageSize(getRows());
Expand Down

0 comments on commit ffa4d6a

Please sign in to comment.