From 2e4cfd552f28a2dab940575ca97ef37de541640e Mon Sep 17 00:00:00 2001 From: Jacques Le Roux Date: Tue, 10 Mar 2015 13:29:40 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1665535 13f79535-47bb-0310-9956-ffa450edef68 --- framework/widget/dtd/widget-form.xsd | 7 +++++++ .../widget/src/org/ofbiz/widget/model/ModelFormField.java | 8 ++++++++ .../ofbiz/widget/renderer/macro/MacroFormRenderer.java | 5 ++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/framework/widget/dtd/widget-form.xsd b/framework/widget/dtd/widget-form.xsd index 606063871a..18f327462a 100644 --- a/framework/widget/dtd/widget-form.xsd +++ b/framework/widget/dtd/widget-form.xsd @@ -1317,6 +1317,13 @@ under the License. + + + + The name of the parent form, needed when using skip-start="true" along with correct id-name value on field + + + diff --git a/framework/widget/src/org/ofbiz/widget/model/ModelFormField.java b/framework/widget/src/org/ofbiz/widget/model/ModelFormField.java index 561e1f7b88..921f4166f3 100644 --- a/framework/widget/src/org/ofbiz/widget/model/ModelFormField.java +++ b/framework/widget/src/org/ofbiz/widget/model/ModelFormField.java @@ -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 getTargetParameterList() { List paramList = new LinkedList(); if (UtilValidate.isNotEmpty(this.targetParameter)) { diff --git a/framework/widget/src/org/ofbiz/widget/renderer/macro/MacroFormRenderer.java b/framework/widget/src/org/ofbiz/widget/renderer/macro/MacroFormRenderer.java index c0df0871ae..26934332f4 100644 --- a/framework/widget/src/org/ofbiz/widget/renderer/macro/MacroFormRenderer.java +++ b/framework/widget/src/org/ofbiz/widget/renderer/macro/MacroFormRenderer.java @@ -2068,7 +2068,10 @@ public final class MacroFormRenderer implements FormStringRenderer { // 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