Author: jleroux Date: Tue Mar 10 13:29:40 2015 New Revision: 1665535 URL: http://svn.apache.org/r1665535 Log: Fixes <<"Lookup fields break when used with a form having skip-start="true">> https://issues.apache.org/jira/browse/OFBIZ-6139
We neglected this aspect so far, adding a "form-name" attribute to the lookup element fixes it. You then need also to set the correct id-name value on field element. Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelFormField.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/macro/MacroFormRenderer.java Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-form.xsd?rev=1665535&r1=1665534&r2=1665535&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original) +++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Tue Mar 10 13:29:40 2015 @@ -1317,6 +1317,13 @@ under the License. <xs:element minOccurs="0" ref="sub-hyperlink" /> </xs:sequence> <xs:attribute type="xs:string" name="target-form-name" use="required" /> + <xs:attribute type="xs:string" name="form-name"> + <xs:annotation> + <xs:documentation> + The name of the parent form, needed when using skip-start="true" along with correct id-name value on field + </xs:documentation> + </xs:annotation> + </xs:attribute> <xs:attribute type="xs:nonNegativeInteger" name="size" default="25" /> <xs:attribute type="xs:positiveInteger" name="maxlength" /> <xs:attribute type="xs:string" name="default-value" /> Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelFormField.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelFormField.java?rev=1665535&r1=1665534&r2=1665535&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelFormField.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelFormField.java Tue Mar 10 13:29:40 2015 @@ -2761,6 +2761,7 @@ public class ModelFormField { private final String descriptionFieldName; private final String fadeBackground; private final FlexibleStringExpander formName; + private final String parentFormName; private final String initiallyCollapsed; private final String lookupHeight; private final String lookupPosition; @@ -2772,6 +2773,7 @@ public class ModelFormField { public LookupField(Element element, ModelFormField modelFormField) { super(element, modelFormField); this.descriptionFieldName = element.getAttribute("description-field-name"); + this.parentFormName = element.getAttribute("form-name"); this.fadeBackground = element.getAttribute("fade-background"); this.formName = FlexibleStringExpander.getInstance(element.getAttribute("target-form-name")); this.initiallyCollapsed = element.getAttribute("initially-collapsed"); @@ -2788,6 +2790,7 @@ public class ModelFormField { this.descriptionFieldName = ""; this.fadeBackground = ""; this.formName = FlexibleStringExpander.getInstance(""); + this.parentFormName = ""; this.initiallyCollapsed = ""; this.lookupHeight = ""; this.lookupPosition = ""; @@ -2802,6 +2805,7 @@ public class ModelFormField { this.descriptionFieldName = original.descriptionFieldName; this.fadeBackground = original.fadeBackground; this.formName = original.formName; + this.parentFormName = original.parentFormName; this.initiallyCollapsed = original.initiallyCollapsed; this.lookupHeight = original.lookupHeight; this.lookupPosition = original.lookupPosition; @@ -2866,6 +2870,10 @@ public class ModelFormField { return targetParameter; } + public String getParentFormName() { + return this.parentFormName; + } + public List<String> getTargetParameterList() { List<String> paramList = new LinkedList<String>(); if (UtilValidate.isNotEmpty(this.targetParameter)) { Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/macro/MacroFormRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/macro/MacroFormRenderer.java?rev=1665535&r1=1665534&r2=1665535&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/macro/MacroFormRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/macro/MacroFormRenderer.java Tue Mar 10 13:29:40 2015 @@ -2068,7 +2068,10 @@ public final class MacroFormRenderer imp // add lookup pop-up button String descriptionFieldName = lookupField.getDescriptionFieldName(); ModelForm modelForm = modelFormField.getModelForm(); - String formName = FormRenderer.getCurrentFormName(modelForm, context); + String formName = lookupField.getParentFormName(); + if (UtilValidate.isEmpty(formName)) { + formName = FormRenderer.getCurrentFormName(modelForm, context); + } StringBuilder targetParameterIter = new StringBuilder(); StringBuilder imgSrc = new StringBuilder(); // FIXME: refactor using the StringUtils methods