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.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@655550 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Adrian Crum
2008-05-12 16:29:30 +00:00
parent 44b401c61e
commit 4fddac4c67
4 changed files with 25 additions and 26 deletions
@@ -28,8 +28,8 @@ under the License.
<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"/>
@@ -100,8 +100,6 @@ under the License.
<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">
+3 -1
View File
@@ -149,7 +149,9 @@ under the License.
</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>
@@ -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) {