Paging Tag Proposal
JSP
<sakaix:dataPager firstRow="{#bBean.firstRow}" maxDisplayedRows="#{bBean.maxDisplayedRows}" dataRows="#{bBean.dataRows}">
Java
// Called during action event handling for a navigation control. public void setFirstRow(int firstRow) { this.firstRow = firstRow; } // Called during action event handling for a range change. public void setMaxDisplayedRows(int maxDisplayedRows) { this.maxDisplayedRows = maxDisplayedRows; } // Called when the dataPager renders, to calculate how many // pages are available for navigation. public int getDataRows() { return realDataCount; } // Called before rendering the table. private initData() { ... dataList = loadPageOfData(firstRow, maxDisplayedRows); ... }
Comments
The MyFaces "x:dataScroller" tag doesn't apply as well to our needs as we'd hoped.
First, it doesn't enforce a particular layout for controls. That's understandable, since it has to be very general. But it means that to match the Style Guide, we'd have to embed many children and not gain much simplification from the component.
Second, MyFaces developers chose to tie their component directly to an existing feature of JSF: UIData's "first", "rows", and "rowCount" fields. This introduces positional dependencies (an "x:dataScroller" tag can't refer to an "x:dataTable" component that appears after it). And this makes it more difficult for application code to take over paging, as we want to be able to do. (Rather than straightforwardly receiving the events it's interested in, the application would need to maintain a binding to the dataTable component and check its values before loading data.)