This task is a sample of how to create and configure a paginated table in an XUI page.
To create a paginated table, the data that is required for the table must first be created. The steps that must be performed to create the data that is required for a paginated table are also described in this task.
For an overview of table pagination and information on the architecture of table pagination for WebSphere® Multichannel Bank Transformation Toolkit, see Table pagination overview and Table pagination architecture. For detailed information on how a table pagination request is handled, see Table pagination request handling.
To create and configure a paginated table in an XUI page, do the following steps:
<kColl id="sampleFlowKColl" dynamic="true"> <refData refId="paginationData"/> <refData refId="tableRow"/> <refData refId="tableData"/> </kColl> <kColl id="paginationData"> <field id="table01_totalRowNumber" value="100"/> <field id="table01_enableNext" value="true"/> <field id="table01_enablePrevious" value="true"/> <field id="table01_errMsg" value="no msg"/> <field id="table01_rowsPerPage" value="15"/> <field id="table01_pageEvent"/> <field id="table01_pageNumber" value="1"/> </kColl> <kColl id="tableRow"> <field id="name"/> <field id="address"/> </kColl> <iColl id="tableData"> <refData refId="tableRow"/> </iColl>
This section provides a sample of how to extend a business operation for a paginated table. After the business operation for a paginated table is created, the business operation is available for selection for the operationNameForPagination property in the Pagination tab of the Properties view.
To extend a business operation for a paginated table, do the following steps:
<context id="pageRetrieverCtx" type="op"> <refKColl refId="pageRetrieverData"/> </context> <kColl id="pageRetrieverData" dynamic="false"> <field id="start" value="0"/> <field id="count" value="15"/> <field id="totalRowNumber" value="101"/> <field id="enableNext" value="true"/> <field id="enablePrevious" value="false"/> <field id="errMsg"/> <field id="sort"/> <field id="rowsPerPage" value="25"/> <field id="pageNumber" value="1"/> <field id="pageEvent"/> <refData refId="item"/> <iColl id="items"> <refData refId="item"/> </iColl> </kColl> <kColl id="item"> <field id="name" value="1"/> <field id="address" value="a"/> </kColl>
IndexedCollection tableData = (IndexedCollection) this.getContext().getKeyedCollection().getElementAt("items"); tableData.removeAll(); Context ctx = getContext(); int size = Integer.parseInt(ctx.getValueAt("rowsPerPage").toString()); int pageNumber = Integer.parseInt(ctx.getValueAt("pageNumber").toString()); if (ctx.getValueAt("pageEvent") != null) { if ("next".equalsIgnoreCase(ctx.getValueAt("pageEvent").toString())) { pageNumber++; } else { pageNumber--; } } for (int i = 0; i < size; i++) { KeyedCollection tableKColl = (KeyedCollection) tableData.createElement(false); tableKColl.setValueAt("name", "BTT"+rand.nextInt()); tableKColl.setValueAt("address", "CDL"+rand.nextInt()); tableData.addElement(tableKColl); } int total = Integer.parseInt(ctx.getValueAt("totalRowNumber").toString()); int pageSize = total / size; if (total % size > 0) { pageSize++; } ctx.setValueAt("totalRowNumber", total); ctx.setValueAt("pageNumber", pageNumber); if (pageNumber <= 1) { ctx.setValueAt("enableNext", "true"); ctx.setValueAt("enablePrevious", "false"); } else if (pageNumber == pageSize) { ctx.setValueAt("enableNext", "false"); ctx.setValueAt("enablePrevious", "true"); } else { ctx.setValueAt("enableNext", "true"); ctx.setValueAt("enablePrevious", "true"); } }