Improved: Backport - Use FlexibleStringExpander for field parameter names.
(OFBIZ-11415)
Allows generation of unique names when repeating rendering of a form on a screen.
Backport cherry-picked from commit 52e21a3d2e with ModelFormFieldTest removed.
This commit is contained in:
@@ -122,7 +122,7 @@ public class ModelFormField {
|
||||
protected final String name;
|
||||
private final List<UpdateArea> onChangeUpdateAreas;
|
||||
private final List<UpdateArea> onClickUpdateAreas;
|
||||
protected final String parameterName;
|
||||
protected final FlexibleStringExpander parameterName;
|
||||
private final Integer position;
|
||||
private final String redWhen;
|
||||
private final Boolean requiredField;
|
||||
@@ -522,7 +522,7 @@ public class ModelFormField {
|
||||
return onClickUpdateAreas;
|
||||
}
|
||||
|
||||
public String getParameterName() {
|
||||
public FlexibleStringExpander getParameterName() {
|
||||
return parameterName;
|
||||
}
|
||||
|
||||
@@ -535,7 +535,7 @@ public class ModelFormField {
|
||||
public String getParameterName(Map<String, ? extends Object> context) {
|
||||
String baseName;
|
||||
if (UtilValidate.isNotEmpty(this.parameterName)) {
|
||||
baseName = this.parameterName;
|
||||
baseName = this.parameterName.expandString(context);
|
||||
} else {
|
||||
baseName = this.name;
|
||||
}
|
||||
@@ -1853,7 +1853,7 @@ public class ModelFormField {
|
||||
public String getParameterNameOther(Map<String, Object> context) {
|
||||
String baseName;
|
||||
if (UtilValidate.isNotEmpty(getModelFormField().parameterName)) {
|
||||
baseName = getModelFormField().parameterName;
|
||||
baseName = getModelFormField().parameterName.expandString(context);
|
||||
} else {
|
||||
baseName = getModelFormField().name;
|
||||
}
|
||||
|
||||
+4
-4
@@ -88,7 +88,7 @@ public class ModelFormFieldBuilder {
|
||||
private String name = "";
|
||||
private List<UpdateArea> onChangeUpdateAreas = new ArrayList<>();
|
||||
private List<UpdateArea> onClickUpdateAreas = new ArrayList<>();
|
||||
private String parameterName = "";
|
||||
private FlexibleStringExpander parameterName = FlexibleStringExpander.getInstance("");
|
||||
private Integer position = null;
|
||||
private String redWhen = "";
|
||||
private Boolean requiredField = null;
|
||||
@@ -133,7 +133,7 @@ public class ModelFormFieldBuilder {
|
||||
this.mapAcsr = FlexibleMapAccessor.getInstance(fieldElement.getAttribute("map-name"));
|
||||
this.modelForm = modelForm;
|
||||
this.name = name;
|
||||
this.parameterName = UtilXml.checkEmpty(fieldElement.getAttribute("parameter-name"), name);
|
||||
this.parameterName = FlexibleStringExpander.getInstance(UtilXml.checkEmpty(fieldElement.getAttribute("parameter-name"), name));
|
||||
String positionAtttr = fieldElement.getAttribute("position");
|
||||
Integer position = null;
|
||||
if (!positionAtttr.isEmpty()) {
|
||||
@@ -406,7 +406,7 @@ public class ModelFormFieldBuilder {
|
||||
return onClickUpdateAreas;
|
||||
}
|
||||
|
||||
public String getParameterName() {
|
||||
public FlexibleStringExpander getParameterName() {
|
||||
return parameterName;
|
||||
}
|
||||
|
||||
@@ -905,7 +905,7 @@ public class ModelFormFieldBuilder {
|
||||
}
|
||||
|
||||
public ModelFormFieldBuilder setParameterName(String parameterName) {
|
||||
this.parameterName = parameterName;
|
||||
this.parameterName = FlexibleStringExpander.getInstance(parameterName);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user