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
This commit is contained in:
Jacques Le Roux
2015-03-10 13:29:40 +00:00
parent a6407914dc
commit 2e4cfd552f
3 changed files with 19 additions and 1 deletions
+7
View File
@@ -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" />
@@ -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)) {
@@ -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