Author: adrianc
Date: Mon May 12 09:29:30 2008 New Revision: 655550 URL: http://svn.apache.org/viewvc?rev=655550&view=rev Log: Implemented page size defaults for the form widget lists. Some code was already there, but it wasn't being used. The form widget defaults to 10 items per page. That setting can be changed with the <form> element view-size attribute. This commit eliminates the need for setting VIEW_SIZE and VIEW_INDEX parameters in the screen definition. I updated an Accounting screen in this commit to demonstrate. Modified: ofbiz/trunk/applications/accounting/widget/GlSetupForms.xml ofbiz/trunk/applications/accounting/widget/GlSetupScreens.xml ofbiz/trunk/framework/widget/dtd/widget-form.xsd ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java Modified: ofbiz/trunk/applications/accounting/widget/GlSetupForms.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/GlSetupForms.xml?rev=655550&r1=655549&r2=655550&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/widget/GlSetupForms.xml (original) +++ ofbiz/trunk/applications/accounting/widget/GlSetupForms.xml Mon May 12 09:29:30 2008 @@ -28,8 +28,8 @@ <field name="accounting" title="${uiLabelMap.CommonEmptyHeader}" use-when="hasBasicPermission" widget-style="buttontext"><hyperlink target="PartyAccountsSummary?organizationPartyId=${partyId}" description="${uiLabelMap.AccountingAccounting}"/></field> </form> - <form name="ListGlAccountOrganization" list-name="listIt" target="" title="" type="list" - odd-row-style="alternate-row" default-table-style="basic-table hover-bar" paginate-target="ListGlAccountOrganization"> + <form name="ListGlAccountOrganization" list-name="listIt" target="" title="" type="list" view-size="50" + default-table-style="basic-table hover-bar" paginate-target="ListGlAccountOrganization"> <actions> <entity-condition entity-name="GlAccountOrganizationAndClass"> <condition-expr field-name="organizationPartyId" env-name="organizationPartyId"/> Modified: ofbiz/trunk/applications/accounting/widget/GlSetupScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/GlSetupScreens.xml?rev=655550&r1=655549&r2=655550&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/widget/GlSetupScreens.xml (original) +++ ofbiz/trunk/applications/accounting/widget/GlSetupScreens.xml Mon May 12 09:29:30 2008 @@ -100,8 +100,6 @@ <set field="titleProperty" value="AccountingChartOfAcctsMenu"/> <set field="tabButtonItem" value="ListGlAccountOrganization"/> <set field="labelTitleProperty" value="${uiLabelMap.AccountingChartOfAcctsMenu}"/> - <set field="viewIndex" from-field="parameters.VIEW_INDEX" type="Integer" default-value="0"/> - <set field="viewSize" from-field="parameters.VIEW_SIZE" type="Integer" default-value="50"/> </actions> <widgets> <decorator-screen name="CommonAdminDecorator"> Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-form.xsd?rev=655550&r1=655549&r2=655550&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original) +++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Mon May 12 09:29:30 2008 @@ -149,7 +149,9 @@ </xs:restriction> </xs:simpleType> </xs:attribute> - <xs:attribute type="xs:string" name="view-size"/> + <xs:attribute type="xs:integer" name="view-size"> + <xs:annotation><xs:documentation>The number of items to display per page</xs:documentation></xs:annotation> + </xs:attribute> <xs:attribute type="xs:string" name="row-count"/> <xs:attribute name="use-row-submit" default="false"> <xs:simpleType> Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java?rev=655550&r1=655549&r2=655550&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java Mon May 12 09:29:30 2008 @@ -162,7 +162,7 @@ public static String DEFAULT_TARGET_TYPE = "intra-app"; /** Pagination settings and defaults. */ - public static int DEFAULT_PAGE_SIZE = 100; + public static int DEFAULT_PAGE_SIZE = 10; protected int defaultViewSize = DEFAULT_PAGE_SIZE; public static String DEFAULT_PAG_INDEX_FIELD = "viewIndex"; public static String DEFAULT_PAG_SIZE_FIELD = "viewSize"; @@ -273,6 +273,7 @@ this.altTargets.addAll(parent.altTargets); this.actions = parent.actions; this.rowActions = parent.rowActions; + this.defaultViewSize = parent.defaultViewSize; //these are done below in a special way... //this.fieldList = parent.fieldList; @@ -2203,7 +2204,7 @@ value = parameters.get("VIEW_INDEX"); if (value == null) { - value = parameters.get(field); + value = parameters.get(field); } } } @@ -2230,32 +2231,32 @@ public int getPaginateSize(Map context) { String field = this.getPaginateSizeField(context); - - int viewSize = DEFAULT_PAGE_SIZE; + + int viewSize = this.defaultViewSize; try { Object value = context.get(field); - + if (value == null) { - // try parameters.VIEW_SIZE as that is an old OFBiz convention - Map parameters = (Map) context.get("parameters"); - if (parameters != null) { - value = parameters.get("VIEW_SIZE"); - - if (value == null) { - value = parameters.get(field); + // try parameters.VIEW_SIZE as that is an old OFBiz convention + Map parameters = (Map) context.get("parameters"); + if (parameters != null) { + value = parameters.get("VIEW_SIZE"); + + if (value == null) { + value = parameters.get(field); + } } } - } - - if (value instanceof Integer) { + + if (value instanceof Integer) { viewSize = ((Integer) value).intValue(); - } else if (value instanceof String) { + } else if (value instanceof String) { viewSize = Integer.parseInt((String) value); } } catch (Exception e) { Debug.logWarning(e, "Error getting paginate view size: " + e.toString(), module); } - + return viewSize; } @@ -2404,13 +2405,11 @@ } public int getViewIndex(Map context) { - Integer value = (Integer) context.get("viewIndex"); - return value != null ? value.intValue() : 0; + return getPaginateIndex(context); } public int getViewSize(Map context) { - Integer value = (Integer) context.get("viewSize"); - return value != null ? value.intValue() : 20; + return getPaginateSize(context); } public int getLowIndex(Map context) { |
Lookin' good Adrian. -David On May 12, 2008, at 10:29 AM, [hidden email] wrote: > Author: adrianc > Date: Mon May 12 09:29:30 2008 > New Revision: 655550 > > URL: http://svn.apache.org/viewvc?rev=655550&view=rev > Log: > Implemented page size defaults for the form widget lists. Some code > was already there, but it wasn't being used. > > The form widget defaults to 10 items per page. That setting can be > changed with the <form> element view-size attribute. > > This commit eliminates the need for setting VIEW_SIZE and VIEW_INDEX > parameters in the screen definition. I updated an Accounting screen > in this commit to demonstrate. > > Modified: > ofbiz/trunk/applications/accounting/widget/GlSetupForms.xml > ofbiz/trunk/applications/accounting/widget/GlSetupScreens.xml > ofbiz/trunk/framework/widget/dtd/widget-form.xsd > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ > ModelForm.java > > Modified: ofbiz/trunk/applications/accounting/widget/GlSetupForms.xml > URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/GlSetupForms.xml?rev=655550&r1=655549&r2=655550&view=diff > = > = > = > = > = > = > = > = > ====================================================================== > --- ofbiz/trunk/applications/accounting/widget/GlSetupForms.xml > (original) > +++ ofbiz/trunk/applications/accounting/widget/GlSetupForms.xml Mon > May 12 09:29:30 2008 > @@ -28,8 +28,8 @@ > <field name="accounting" title="$ > {uiLabelMap.CommonEmptyHeader}" use-when="hasBasicPermission" widget- > style="buttontext"><hyperlink target="PartyAccountsSummary? > organizationPartyId=${partyId}" description="$ > {uiLabelMap.AccountingAccounting}"/></field> > </form> > > - <form name="ListGlAccountOrganization" list-name="listIt" > target="" title="" type="list" > - odd-row-style="alternate-row" default-table-style="basic- > table hover-bar" paginate-target="ListGlAccountOrganization"> > + <form name="ListGlAccountOrganization" list-name="listIt" > target="" title="" type="list" view-size="50" > + default-table-style="basic-table hover-bar" paginate- > target="ListGlAccountOrganization"> > <actions> > <entity-condition entity- > name="GlAccountOrganizationAndClass"> > <condition-expr field-name="organizationPartyId" env- > name="organizationPartyId"/> > > Modified: ofbiz/trunk/applications/accounting/widget/ > GlSetupScreens.xml > URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/GlSetupScreens.xml?rev=655550&r1=655549&r2=655550&view=diff > = > = > = > = > = > = > = > = > ====================================================================== > --- ofbiz/trunk/applications/accounting/widget/GlSetupScreens.xml > (original) > +++ ofbiz/trunk/applications/accounting/widget/GlSetupScreens.xml > Mon May 12 09:29:30 2008 > @@ -100,8 +100,6 @@ > <set field="titleProperty" > value="AccountingChartOfAcctsMenu"/> > <set field="tabButtonItem" > value="ListGlAccountOrganization"/> > <set field="labelTitleProperty" value="$ > {uiLabelMap.AccountingChartOfAcctsMenu}"/> > - <set field="viewIndex" from- > field="parameters.VIEW_INDEX" type="Integer" default-value="0"/> > - <set field="viewSize" from- > field="parameters.VIEW_SIZE" type="Integer" default-value="50"/> > </actions> > <widgets> > <decorator-screen name="CommonAdminDecorator"> > > Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-form.xsd?rev=655550&r1=655549&r2=655550&view=diff > = > = > = > = > = > = > = > = > ====================================================================== > --- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original) > +++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Mon May 12 > 09:29:30 2008 > @@ -149,7 +149,9 @@ > </xs:restriction> > </xs:simpleType> > </xs:attribute> > - <xs:attribute type="xs:string" name="view-size"/> > + <xs:attribute type="xs:integer" name="view-size"> > + <xs:annotation><xs:documentation>The number of items to > display per page</xs:documentation></xs:annotation> > + </xs:attribute> > <xs:attribute type="xs:string" name="row-count"/> > <xs:attribute name="use-row-submit" default="false"> > <xs:simpleType> > > Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ > ModelForm.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java?rev=655550&r1=655549&r2=655550&view=diff > = > = > = > = > = > = > = > = > ====================================================================== > --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ > ModelForm.java (original) > +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ > ModelForm.java Mon May 12 09:29:30 2008 > @@ -162,7 +162,7 @@ > public static String DEFAULT_TARGET_TYPE = "intra-app"; > > /** Pagination settings and defaults. */ > - public static int DEFAULT_PAGE_SIZE = 100; > + public static int DEFAULT_PAGE_SIZE = 10; > protected int defaultViewSize = DEFAULT_PAGE_SIZE; > public static String DEFAULT_PAG_INDEX_FIELD = "viewIndex"; > public static String DEFAULT_PAG_SIZE_FIELD = "viewSize"; > @@ -273,6 +273,7 @@ > this.altTargets.addAll(parent.altTargets); > this.actions = parent.actions; > this.rowActions = parent.rowActions; > + this.defaultViewSize = parent.defaultViewSize; > > //these are done below in a special way... > //this.fieldList = parent.fieldList; > @@ -2203,7 +2204,7 @@ > value = parameters.get("VIEW_INDEX"); > > if (value == null) { > - value = parameters.get(field); > + value = parameters.get(field); > } > } > } > @@ -2230,32 +2231,32 @@ > > public int getPaginateSize(Map context) { > String field = this.getPaginateSizeField(context); > - > - int viewSize = DEFAULT_PAGE_SIZE; > + > + int viewSize = this.defaultViewSize; > try { > Object value = context.get(field); > - > + > if (value == null) { > - // try parameters.VIEW_SIZE as that is an old OFBiz > convention > - Map parameters = (Map) context.get("parameters"); > - if (parameters != null) { > - value = parameters.get("VIEW_SIZE"); > - > - if (value == null) { > - value = parameters.get(field); > + // try parameters.VIEW_SIZE as that is an old OFBiz > convention > + Map parameters = (Map) context.get("parameters"); > + if (parameters != null) { > + value = parameters.get("VIEW_SIZE"); > + > + if (value == null) { > + value = parameters.get(field); > + } > } > } > - } > - > - if (value instanceof Integer) { > + > + if (value instanceof Integer) { > viewSize = ((Integer) value).intValue(); > - } else if (value instanceof String) { > + } else if (value instanceof String) { > viewSize = Integer.parseInt((String) value); > } > } catch (Exception e) { > Debug.logWarning(e, "Error getting paginate view size: " > + e.toString(), module); > } > - > + > return viewSize; > } > > @@ -2404,13 +2405,11 @@ > } > > public int getViewIndex(Map context) { > - Integer value = (Integer) context.get("viewIndex"); > - return value != null ? value.intValue() : 0; > + return getPaginateIndex(context); > } > > public int getViewSize(Map context) { > - Integer value = (Integer) context.get("viewSize"); > - return value != null ? value.intValue() : 20; > + return getPaginateSize(context); > } > > public int getLowIndex(Map context) { > > |
Free forum by Nabble | Edit this page |