我使用lazyquerycontainer插件的EntityContainer類。顧名思義,它支持延遲加載。這只是工作:)
一些示例代碼:
resultsTable = new Table();
resultsTable.setSelectable(true);
resultsTable.setCaption("JpaQuery");
resultsTable.setPageLength(40);
resultsTable.setImmediate(true);
resultsTable.setEditable(false);
resultsTable.setWriteThrough(true);
container = new EntityContainer<Call>(em, false, true, true, Call.class, 100, new Object[] {"imsi"}, new boolean[] {true});
container.addContainerProperty(LazyQueryView.PROPERTY_ID_ITEM_STATUS, QueryItemStatus.class, QueryItemStatus.None, true, false);
container.addContainerProperty("startTime", Date.class, null, true, true);
container.addContainerProperty("stopTime", Date.class, null, true, true);
container.addContainerProperty("imsi", String.class, null, false, true);
container.addContainerProperty("imei", String.class, null, false, true);
container.addContainerProperty("callType", Integer.class, null, true, true);
container.addContainerProperty("cdpn", String.class, null, true, true);
container.addContainerProperty("cgpn", String.class, null, true, true);
container.addContainerProperty("status", Integer.class, null, true, true);
container.addContainerProperty("mmRelCause", Integer.class, null, true, true);
container.addContainerProperty("rrRelCause", Integer.class, null, true, true);
resultsTable.setContainerDataSource(container);
resultsTable.setVisibleColumns(new String[] {"startTime" , "stopTime" , "imsi", "imei", "callType" , "cdpn", "cgpn", "status", "mmRelCause" , "rrRelCause" });
resultsTable.setColumnHeaders(new String[] {"Start time", "Stop time", "IMSI", "IMEI", "Call Type", "CDPN", "CGPN", "Status", "MM Release Cause", "RR Release Cause"});
resultsTable.setColumnCollapsingAllowed(true);
resultsTable.setColumnCollapsed("mmRelCause", true);
resultsTable.setColumnCollapsed("rrRelCause", true);
要過濾JQL數據築底,您可以執行filter
方法經過過濾字符串和綁定變量的地圖。
...
whereParameters.put("stopTimeFrom", filterParams.getStopTimeFrom());
where = "e.startTime >= :stopTimeFrom";
...
container.filter(where, whereParameters);
如果您預先判斷標準API,則可以使用criteriacontainer。