From 4fddac4c6705246d759b599e85d19a28cb65331e Mon Sep 17 00:00:00 2001 From: Adrian Crum Date: Mon, 12 May 2008 16:29:30 +0000 Subject: [PATCH] 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
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. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@655550 13f79535-47bb-0310-9956-ffa450edef68 --- .../accounting/widget/GlSetupForms.xml | 4 +- .../accounting/widget/GlSetupScreens.xml | 2 - framework/widget/dtd/widget-form.xsd | 4 +- .../src/org/ofbiz/widget/form/ModelForm.java | 41 +++++++++---------- 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/applications/accounting/widget/GlSetupForms.xml b/applications/accounting/widget/GlSetupForms.xml index b1642673a4..7e588e9526 100644 --- a/applications/accounting/widget/GlSetupForms.xml +++ b/applications/accounting/widget/GlSetupForms.xml @@ -28,8 +28,8 @@ under the License.
-
+ diff --git a/applications/accounting/widget/GlSetupScreens.xml b/applications/accounting/widget/GlSetupScreens.xml index 151151d14c..d303b0511f 100644 --- a/applications/accounting/widget/GlSetupScreens.xml +++ b/applications/accounting/widget/GlSetupScreens.xml @@ -100,8 +100,6 @@ under the License. - - diff --git a/framework/widget/dtd/widget-form.xsd b/framework/widget/dtd/widget-form.xsd index 6435a11ce1..58fc6f61fb 100644 --- a/framework/widget/dtd/widget-form.xsd +++ b/framework/widget/dtd/widget-form.xsd @@ -149,7 +149,9 @@ under the License. - + + The number of items to display per page + diff --git a/framework/widget/src/org/ofbiz/widget/form/ModelForm.java b/framework/widget/src/org/ofbiz/widget/form/ModelForm.java index f8216ef338..428648d902 100644 --- a/framework/widget/src/org/ofbiz/widget/form/ModelForm.java +++ b/framework/widget/src/org/ofbiz/widget/form/ModelForm.java @@ -162,7 +162,7 @@ public class ModelForm extends ModelWidget { 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 @@ public class ModelForm extends ModelWidget { 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 @@ public class ModelForm extends ModelWidget { value = parameters.get("VIEW_INDEX"); if (value == null) { - value = parameters.get(field); + value = parameters.get(field); } } } @@ -2230,32 +2231,32 @@ public class ModelForm extends ModelWidget { 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 class ModelForm extends ModelWidget { } 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) {