Author: adrianc
Date: Thu Jan 5 07:10:26 2012 New Revision: 1227505 URL: http://svn.apache.org/viewvc?rev=1227505&view=rev Log: Screen Widget Redesign - update branch from trunk. Modified: ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/ (props changed) ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/dtd/widget-form.xsd ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/form/ModelForm.java ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java Propchange: ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Thu Jan 5 07:10:26 2012 @@ -2,4 +2,5 @@ /ofbiz/branches/dojo1.4/framework/widget:951708-952957 /ofbiz/branches/jquery/framework/widget:952958-1044489 /ofbiz/branches/multitenant20100310/framework/widget:921280-927264 -/ofbiz/trunk/framework/widget:1204170,1206013,1209250 +/ofbiz/trunk/framework/widget:1204170,1206013,1209250,1220927,1221913,1227340,1227365 +/ofbiz/trunk/framework/widget/framework/widget:1220927 Modified: ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/dtd/widget-form.xsd URL: http://svn.apache.org/viewvc/ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/dtd/widget-form.xsd?rev=1227505&r1=1227504&r2=1227505&view=diff ============================================================================== --- ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/dtd/widget-form.xsd (original) +++ ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/dtd/widget-form.xsd Thu Jan 5 07:10:26 2012 @@ -356,6 +356,7 @@ under the License. <xs:element name="sort-field"> <xs:complexType> <xs:attributeGroup ref="attlist.sort-field"/> + <xs:attribute name="position" type="xs:positiveInteger"/> </xs:complexType> </xs:element> <xs:attributeGroup name="attlist.sort-field"> Modified: ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java?rev=1227505&r1=1227504&r2=1227505&view=diff ============================================================================== --- ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java (original) +++ ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java Thu Jan 5 07:10:26 2012 @@ -843,13 +843,11 @@ public class MacroFormRenderer implement options.append(key); options.append("'"); options.append(",'description':'"); - String description = encode(optionValue.getDescription(), modelFormField, context); - String unescaped = StringEscapeUtils.unescapeHtml(description); - if (textSize > 0 && unescaped.length() > textSize ) { - String reduced = unescaped.substring(0, textSize - 8) + "..." + unescaped.substring(unescaped.length() - 5); - description = StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(reduced)); + String description = optionValue.getDescription(); + if (textSize > 0 && description.length() > textSize ) { + description = description.substring(0, textSize - 8) + "..." + description.substring(description.length() - 5); } - options.append(description); + options.append(encode(description, modelFormField, context)); if (UtilValidate.isNotEmpty(currentValueList)) { options.append("'"); @@ -1424,7 +1422,7 @@ public class MacroFormRenderer implement Iterator<ModelFormField> submitFields = modelForm.getMultiSubmitFields().iterator(); while (submitFields.hasNext()) { ModelFormField submitField = submitFields.next(); - if (submitField != null) { + if (submitField != null && submitField.shouldUse(context)) { // Threw this in that as a hack to keep the submit button from expanding the first field // Needs a more rugged solution Modified: ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/form/ModelForm.java URL: http://svn.apache.org/viewvc/ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/form/ModelForm.java?rev=1227505&r1=1227504&r2=1227505&view=diff ============================================================================== --- ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/form/ModelForm.java (original) +++ ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/form/ModelForm.java Thu Jan 5 07:10:26 2012 @@ -132,7 +132,7 @@ public class ModelForm extends ModelWidg protected List<AltTarget> altTargets = FastList.newInstance(); protected List<AutoFieldsService> autoFieldsServices = FastList.newInstance(); protected List<AutoFieldsEntity> autoFieldsEntities = FastList.newInstance(); - protected List<String> sortOrderFields = FastList.newInstance(); + protected List<SortField> sortOrderFields = FastList.newInstance(); protected List<AltRowStyle> altRowStyles = FastList.newInstance(); /** This List will contain one copy of each field for each field name in the order @@ -542,7 +542,8 @@ public class ModelForm extends ModelWidg String tagName = sortFieldElement.getTagName(); if (tagName.equals("sort-field")) { String fieldName = sortFieldElement.getAttribute("name"); - this.sortOrderFields.add(fieldName); + String position = sortFieldElement.getAttribute("position"); + this.sortOrderFields.add(new SortField(fieldName, position)); this.fieldGroupMap.put(fieldName, lastFieldGroup); } else if (tagName.equals("banner")) { Banner thisBanner = new Banner(sortFieldElement, this); @@ -563,7 +564,8 @@ public class ModelForm extends ModelWidg // reorder fields according to sort order if (sortOrderFields.size() > 0) { List<ModelFormField> sortedFields = FastList.newInstance(); - for (String fieldName: this.sortOrderFields) { + for (SortField sortField: this.sortOrderFields) { + String fieldName = sortField.getFieldName(); if (UtilValidate.isEmpty(fieldName)) { continue; } @@ -574,6 +576,9 @@ public class ModelForm extends ModelWidg ModelFormField modelFormField = fieldIter.next(); if (fieldName.equals(modelFormField.getName())) { // matched the name; remove from the original last and add to the sorted list + if (UtilValidate.isNotEmpty(sortField.getPosition())) { + modelFormField.setPosition(sortField.getPosition()); + } fieldIter.remove(); sortedFields.add(modelFormField); } @@ -2898,6 +2903,35 @@ public class ModelForm extends ModelWidg } } + public static class SortField { + protected String fieldName; + protected Integer position = null; + + public SortField(String name, String position) { + this.fieldName = name; + if (UtilValidate.isNotEmpty(position)){ + Integer posParam = null; + try { + posParam = Integer.valueOf(position); + } + catch(Exception e) {/* just ignore the exception*/} + this.position = posParam; + } + } + + public SortField(String name) { + this(name, null); + } + + public String getFieldName() { + return this.fieldName; + } + + public Integer getPosition() { + return this.position; + } + } + public static interface FieldGroupBase {} public static class FieldGroup implements FieldGroupBase { @@ -2927,7 +2961,7 @@ public class ModelForm extends ModelWidg } for (Element sortFieldElement: UtilXml.childElementList(sortOrderElement, "sort-field")) { - modelForm.sortOrderFields.add(sortFieldElement.getAttribute("name")); + modelForm.sortOrderFields.add(new SortField(sortFieldElement.getAttribute("name"),sortFieldElement.getAttribute("position"))); modelForm.fieldGroupMap.put(sortFieldElement.getAttribute("name"), this); } } else { Modified: ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java URL: http://svn.apache.org/viewvc/ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java?rev=1227505&r1=1227504&r2=1227505&view=diff ============================================================================== --- ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java (original) +++ ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java Thu Jan 5 07:10:26 2012 @@ -371,7 +371,12 @@ public abstract class ModelFormAction { try { Map<String, Object> serviceContext = null; if (autoFieldMapBool) { - serviceContext = WidgetWorker.getDispatcher(context).getDispatchContext().makeValidContext(serviceNameExpanded, ModelService.IN_PARAM, context); + if (! "true".equals(autoFieldMapString)) { + Map<String, Object> autoFieldMap = UtilGenerics.checkMap(context.get(autoFieldMapString)); + serviceContext = WidgetWorker.getDispatcher(context).getDispatchContext().makeValidContext(serviceNameExpanded, ModelService.IN_PARAM, autoFieldMap); + } else { + serviceContext = WidgetWorker.getDispatcher(context).getDispatchContext().makeValidContext(serviceNameExpanded, ModelService.IN_PARAM, context); + } } else { serviceContext = new HashMap<String, Object>(); } |
Free forum by Nabble | Edit this page |