From: Chad B. <cwb...@us...> - 2008-04-02 22:37:42
|
User: cwbrandon Date: 08/04/02 15:37:48 Modified: andromda-jsf2/src/main/resources/templates/jsf2/views/portlet view-table.xhtml.vsl andromda-jsf2/src/main/resources/templates/jsf2/utils/portlet PageableDataModel.java.vsl Log: improvements to portlet table and pageable data model Revision Changes Path 1.7 +1 -1 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/views/portlet/view-table.xhtml.vsl Index: view-table.xhtml.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/views/portlet/view-table.xhtml.vsl,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -r1.6 -r1.7 --- view-table.xhtml.vsl 27 Mar 2008 23:39:18 -0000 1.6 +++ view-table.xhtml.vsl 2 Apr 2008 22:37:47 -0000 1.7 @@ -71,7 +71,7 @@ #end <h:column> <f:facet name="header"> - <t:commandSortHeader columnName="$columnName" arrow="true"> + <t:commandSortHeader columnName="$columnName" arrow="true" propertyName="$columnName"> <h:outputText value="#{messages['$table.getTableColumnMessageKey($columnName)']}"/> </t:commandSortHeader> </f:facet> 1.4 +25 -38 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/utils/portlet/PageableDataModel.java.vsl Index: PageableDataModel.java.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/utils/portlet/PageableDataModel.java.vsl,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -r1.3 -r1.4 --- PageableDataModel.java.vsl 31 Mar 2008 22:48:57 -0000 1.3 +++ PageableDataModel.java.vsl 2 Apr 2008 22:37:48 -0000 1.4 @@ -71,7 +71,7 @@ */ public $paginationResultClassName getPage() { - if (this.page == null) + if (this.page == null || this.forcePageRefresh) { this.page = this.getPage( @@ -79,6 +79,7 @@ this.pageSize, this.sortProperty, this.sortAscending); + this.forcePageRefresh = false; } return this.page; } @@ -98,6 +99,21 @@ return pageNumber; } + private javax.faces.component.UIData owner; + + /** + * Sets the UIData owner of this pageable data model. + */ + public void setOwner(javax.faces.component.UIData owner) + { + this.owner = owner; + } + + private int getFirst() + { + return this.owner != null ? this.owner.getFirst() : -1; + } + /** * Keeps track of the previous row index (so that we don't search more than we need) */ @@ -120,15 +136,14 @@ final int listIndex = this.rowIndex % this.pageSize; if (this.forcePageRefresh || listIndex == 0 && this.previousRowIndex != this.rowIndex) { + final int first = this.getFirst(); + if (!this.forcePageRefresh) + { + this.forcePageRefresh = this.previousRowIndex != this.rowIndex && + (first == -1 || (this.rowIndex >= first && this.rowIndex <= (first + this.pageSize))); + } + page = this.getPage(); this.previousRowIndex = this.rowIndex; - // - only search if the listIndex is 0 (that is its a multiple of the page size) - page = - this.getPage( - this.getPageNumber(), - pageSize, - this.sortProperty, - this.sortAscending); - this.forcePageRefresh = false; } Object rowData = null; if (page.getData() != null) @@ -188,34 +203,6 @@ String sortProperty, boolean sortAscending); - /* Used by ADF - public Object getRowKey() - { - return isRowAvailable() ? String.valueOf(getRowIndex()) : null; - } - - public void setRowKey(Object key) - { - setRowIndex(this.toRowIndex((String)key)); - } - - /** - * Creates a row index for the given row key - * - private int toRowIndex(String rowKey) - { - int rowIndex = -1; - try - { - rowIndex = Integer.parseInt(rowKey); - } - catch (NumberFormatException exception) - { - // - ignore - } - return rowIndex; - }*/ - private boolean forcePageRefresh; private String sortProperty; @@ -243,7 +230,7 @@ public void setSortAscending(boolean sortAscending) { - if (sortAscending != sortAscending) + if (this.sortAscending != sortAscending) { this.forcePageRefresh = true; } |