From: Chad B. <cwb...@us...> - 2008-04-03 19:56:38
|
User: cwbrandon Date: 08/04/03 12:56:42 Modified: andromda-jsf2/src/main/resources/templates/jsf2/utils/portlet PageableDataModel.java.vsl Log: Reset the owner component's first value when the data model is created Revision Changes Path 1.7 +27 -8 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.6 retrieving revision 1.7 diff -u -w -r1.6 -r1.7 --- PageableDataModel.java.vsl 3 Apr 2008 16:23:47 -0000 1.6 +++ PageableDataModel.java.vsl 3 Apr 2008 19:56:41 -0000 1.7 @@ -71,6 +71,7 @@ */ public $paginationResultClassName getPage() { + this.initialize(); if (this.page == null || this.forcePageRefresh) { this.page = @@ -84,7 +85,7 @@ return this.page; } - private int getPageNumber() + protected int getPageNumber() { int pageNumber = 1; int rowIndex = this.rowIndex + 1; @@ -104,7 +105,7 @@ * * @return the first record number. */ - private int getFirst() + protected int getFirst() { final javax.faces.component.UIData owner = this.findOwner(); return owner != null ? owner.getFirst() : -1; @@ -120,14 +121,27 @@ private static final String SORT_ASCENDING = "sortAscending"; /** + * When this pageable data model is created a reset is required (i.e. + * setting first to 0 on the owner and resetting the rowIndex to 0 + */ + private boolean resetRequired = true; + + /** * Finds the component that "owns" this data model. * * @return the owne component (i.e. table). */ - private javax.faces.component.UIData findOwner() + protected javax.faces.component.UIData findOwner() + { + return (javax.faces.component.UIData)findOwner(javax.faces.context.FacesContext.getCurrentInstance().getViewRoot()); + } + + /** + * Performs any required initialization. + */ + protected void initialize() { - final javax.faces.component.UIData owner = - (javax.faces.component.UIData)findOwner(javax.faces.context.FacesContext.getCurrentInstance().getViewRoot()); + final javax.faces.component.UIData owner = this.findOwner(); if (owner != null) { final Object sortProperty = this.getProperty(owner, SORT_PROPERTY); @@ -140,11 +154,16 @@ { this.setSortAscending((Boolean)sortAscending); } + if (this.resetRequired) + { + owner.setFirst(0); + this.setRowIndex(0); + this.resetRequired = false; + } } - return owner; } - private Object getProperty(final javax.faces.component.UIData owner, String name) + protected Object getProperty(final javax.faces.component.UIData owner, String name) { Object property = null; if (owner != null) @@ -170,7 +189,7 @@ * @param component the component to start the search with. * @return the owne component (i.e. table). */ - private javax.faces.component.UIComponent findOwner(final javax.faces.component.UIComponent component) + protected javax.faces.component.UIComponent findOwner(final javax.faces.component.UIComponent component) { javax.faces.component.UIComponent owner = null; if (component instanceof javax.faces.component.UIData) |