-
Notifications
You must be signed in to change notification settings - Fork 763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DataTable: LazyDataModel.load gets invoked multiple times when datatable is lazy and has headerRow #11452
Comments
coderoth
added
‼️ needs-triage
Issue needs triaging
🐞 defect
Bug...Something isn't working
labels
Feb 16, 2024
It was introduced by this ticket: #9077 cc @sebsoftware Looking at the source code it seems this was intentional with a comment in the // in case of a lazy DataTable, the LazyDataModel currently only loads rows inside the current page; we need a small hack here
// 1) get the rowData manually for the next row
// 2) put it into request-scope
// 3) invoke the groupBy ValueExpression
if (table.isLazy()) {
Object nextRowData = table.getLazyDataModel().getRowData(nextRowIndex, table.getActiveSortMeta(), table.getActiveFilterMeta());
if (nextRowData == null) {
return false;
}
nextGroupByData = ComponentUtils.executeInRequestScope(context, table.getVar(), nextRowData, () -> groupByVE.getValue(elContext));
} |
Rapster
added a commit
to Rapster/primefaces
that referenced
this issue
Feb 18, 2024
…tiple times when datatable is lazy and has headerRow
Indeed, that extra call is not needed when no summaryRow present |
melloware
added
⚡ performance
Performance related issue or enhancement
and removed
🐞 defect
Bug...Something isn't working
labels
Feb 19, 2024
melloware
added a commit
that referenced
this issue
Feb 19, 2024
#11457) * Fix #11452 - DataTable: LazyDataModel.load gets invoked multiple times when datatable is lazy and has headerRow * Fix and rename LazyDataModel#getRowData into LazyDataModel#loadOne to avoid confusion * Update 14_0_0.md * Update LazyDataModel.java * Update DataTableRenderer.java * Update 14_0_0.md * Update DataTableRenderer.java * Update LazyDataModel.java --------- Co-authored-by: Melloware <mellowaredev@gmail.com>
melloware
added a commit
to melloware/primefaces
that referenced
this issue
Feb 19, 2024
…ked multiple times
melloware
added a commit
that referenced
this issue
Feb 19, 2024
Wow, thanks for the fix! |
13.0.6 is in Maven Central if you want to try it @coderoth |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
DataTable component invokes LazyDataModel::load multiple times (one for each item in the current page of the datatable) when the datatable is lazy and has a headerRow.
Please, check the attached zip that reproduces the problem and shows one workaround to the issue.
To execute the reproducer:
And open the following page in the browser
primefaces-test.zip
Reproducer
The ProblematicLazyDataModel::load method below will be executed multiple times (one for each returned item in the pagination). With datatable configured with
rows=5
, this is the server output (showing that querying a real database would result in 5 queries being executed with weird pagination parameters):Please, check provided uploaded primefaces-test.zip for a working and complete example.
Sample xhtml:
Sample problematic datamodel:
Expected behavior
DataTable should invoke the LazyDataModel::load method once, like que WorkaroundLazyDataModel example below.
The output:
WorkaroundLazyDataModel code, with overriden getRowData method (the workaround):
PrimeFaces edition
Community
PrimeFaces version
13.0.5
Theme
No response
JSF implementation
Mojarra
JSF version
2.3.21
Java version
1.8.0_361
Browser(s)
No response
The text was updated successfully, but these errors were encountered: