A slightly modified patch from Niclas Malin for "New elements auto-parameters-[entity/service] for link/hyperlink" https://issues.apache.org/jira/browse/OFBIZ-4472

When you want edit/remove an entity from link call it's needed to give all pk on parameter element as like :
{quote}         <field name="deleteLink">
            <hyperlink target="example_deleteExampleFeatureAppl">
                <parameter param-name="exampleId"/>
                <parameter param-name="exampleFeatureId"/>
                <parameter param-name="fromDate"/>
            <hyperlink/>
         </field>
{quote}

To simplify, I introduce auto-parameters-entity like this :
{quote}
         <field name="deleteLink">
            <hyperlink target="example_deleteExampleFeatureAppl">
                <auto-parameters-entity entity-name="ExampleFeatureAppl"/>
            <hyperlink/>
         </field>
{quote}
or 
{quote}
         <form name="ListExampleFeatureAppls" type="list" default-entity-name="ExampleFeatureAppl">
         <field name="deleteLink">
            <hyperlink target="example_deleteExampleFeatureAppl">
                <auto-parameters-entity/>
            <hyperlink/>
         </field>
{quote}
This method is inspired from auto-fields-entity and I homogenized on widget renderer screen (link), menu (link) and form (hyperlink, sub-link)

jleroux: I simply put returns in case of no dispatcher or delegator



git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1506835 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jacques Le Roux
2013-07-25 07:52:45 +00:00
parent f3a1c6455a
commit 26e2c7744a
8 changed files with 427 additions and 13 deletions
+60
View File
@@ -426,6 +426,8 @@ under the License.
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" ref="auto-parameters-service"/>
<xs:element minOccurs="0" ref="auto-parameters-entity"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="parameter" />
</xs:sequence>
<xs:attribute name="event-type" use="required">
@@ -962,6 +964,8 @@ under the License.
<xs:element name="hyperlink" substitutionGroup="AllFields">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" ref="auto-parameters-service"/>
<xs:element minOccurs="0" ref="auto-parameters-entity"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="parameter" />
</xs:sequence>
<xs:attribute name="also-hidden" default="true">
@@ -1055,6 +1059,60 @@ under the License.
<xs:attribute type="xs:string" name="value" />
</xs:complexType>
</xs:element>
<xs:element name="auto-parameters-service">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="exclude"/>
</xs:sequence>
<xs:attribute name="service-name" type="xs:string">
<xs:annotation>
<xs:documentation>The service name used to resolve parameters. If empty, use form defaultServiceName. Flexible string allowed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="send-if-empty" default="true">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="true"/>
<xs:enumeration value="false"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="auto-parameters-entity">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="exclude"/>
</xs:sequence>
<xs:attribute name="entity-name" type="xs:string">
<xs:annotation>
<xs:documentation>The entity name used to resolve parameters. If empty use form defaultEntityName attribute. Flexible string allowed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="include" default="pk">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="pk"/>
<xs:enumeration value="nonpk"/>
<xs:enumeration value="all"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="send-if-empty" default="true">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="true"/>
<xs:enumeration value="false"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="exclude">
<xs:complexType>
<xs:attribute name="field-name" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="ignored" substitutionGroup="AllFields">
<xs:complexType/>
</xs:element>
@@ -1699,6 +1757,8 @@ under the License.
<xs:element name="sub-hyperlink">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" ref="auto-parameters-service"/>
<xs:element minOccurs="0" ref="auto-parameters-entity"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="parameter" />
</xs:sequence>
<xs:attribute type="xs:string" name="use-when" />
+56
View File
@@ -148,6 +148,8 @@ under the License.
<xs:element name="link">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" ref="auto-parameters-service"/>
<xs:element minOccurs="0" ref="auto-parameters-entity"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="parameter" />
<xs:element minOccurs="0" ref="image" />
</xs:sequence>
@@ -231,6 +233,60 @@ under the License.
<xs:attribute type="xs:string" name="value" />
</xs:complexType>
</xs:element>
<xs:element name="auto-parameters-service">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="exclude"/>
</xs:sequence>
<xs:attribute name="service-name" type="xs:string" use="required">
<xs:annotation>
<xs:documentation>The service name used to resolve parameters. Flexible string allowed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="send-if-empty" default="true">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="true"/>
<xs:enumeration value="false"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="auto-parameters-entity">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="exclude"/>
</xs:sequence>
<xs:attribute name="entity-name" type="xs:string">
<xs:annotation>
<xs:documentation>The entity name used to resolve parameters. If empty try use menu defaultEntityName attribute. Flexible string allowed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="include" default="pk">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="pk"/>
<xs:enumeration value="nonpk"/>
<xs:enumeration value="all"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="send-if-empty" default="true">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="true"/>
<xs:enumeration value="false"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="exclude">
<xs:complexType>
<xs:attribute name="field-name" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<!-- ================ ACTIONS ================ -->
<xs:element name="AllActions" abstract="true"/>
+56
View File
@@ -772,6 +772,8 @@ under the License.
<xs:element name="link" substitutionGroup="AllWidgets">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" ref="auto-parameters-service"/>
<xs:element minOccurs="0" ref="auto-parameters-entity"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="parameter" />
<xs:element minOccurs="0" ref="image" />
</xs:sequence>
@@ -841,6 +843,60 @@ under the License.
<xs:attribute type="xs:string" name="value" />
</xs:complexType>
</xs:element>
<xs:element name="auto-parameters-service">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="exclude"/>
</xs:sequence>
<xs:attribute name="service-name" type="xs:string" use="required">
<xs:annotation>
<xs:documentation>The service name used to resolve parameters. If empty, use form defaultServiceName. Flexible string allowed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="send-if-empty" default="true">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="true"/>
<xs:enumeration value="false"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="auto-parameters-entity">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="exclude"/>
</xs:sequence>
<xs:attribute name="entity-name" type="xs:string" use="required">
<xs:annotation>
<xs:documentation>The entity name used to resolve parameters. If empty use form defaultEntityName attribute. Flexible string allowed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="include" default="pk">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="pk"/>
<xs:enumeration value="nonpk"/>
<xs:enumeration value="all"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="send-if-empty" default="true">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="true"/>
<xs:enumeration value="false"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="exclude">
<xs:complexType>
<xs:attribute name="field-name" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="screenlet" substitutionGroup="AllWidgets">
<xs:complexType>
@@ -25,6 +25,8 @@ import java.math.BigDecimal;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.text.DateFormat;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
@@ -32,16 +34,25 @@ import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javolution.util.FastList;
import javolution.util.FastMap;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.StringUtil;
import org.ofbiz.base.util.UtilDateTime;
import org.ofbiz.base.util.UtilGenerics;
import org.ofbiz.base.util.UtilHttp;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.UtilXml;
import org.ofbiz.base.util.collections.FlexibleMapAccessor;
import org.ofbiz.base.util.string.FlexibleStringExpander;
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.model.ModelEntity;
import org.ofbiz.entity.model.ModelField;
import org.ofbiz.service.GenericServiceException;
import org.ofbiz.service.LocalDispatcher;
import org.ofbiz.service.ModelParam;
import org.ofbiz.service.ModelService;
import org.ofbiz.webapp.control.ConfigXMLReader;
import org.ofbiz.webapp.control.RequestHandler;
import org.ofbiz.webapp.taglib.ContentUrlTag;
@@ -396,6 +407,128 @@ public class WidgetWorker {
}
}
public static class AutoServiceParameters {
private String serviceName;
List<String> excludeList = FastList.newInstance();
boolean includePk;
boolean includeNonPk;
boolean sendIfEmpty;
public AutoServiceParameters(Element autoElement){
serviceName = UtilXml.checkEmpty(autoElement.getAttribute("service-name"));
sendIfEmpty = "true".equals(autoElement.getAttribute("send-if-empty"));
List<? extends Element> excludes = UtilXml.childElementList(autoElement, "exclude");
if (excludes != null) {
for (Element exclude: excludes) {
if (UtilValidate.isNotEmpty(exclude.getAttribute("field-name"))) {
excludeList.add(exclude.getAttribute("field-name"));
}
}
}
}
public Map<String, String> getParametersMap(Map<String, Object> context, String defaultServiceName) {
Map<String, String> autServiceParams = FastMap.newInstance();
LocalDispatcher dispatcher = (LocalDispatcher) context.get("dispatcher");
if (dispatcher == null) {
Debug.logError("We can not append auto service Parameters since we could not find dispatcher in the current context", module);
return autServiceParams;
}
if (UtilValidate.isEmpty(serviceName)) serviceName = defaultServiceName;
FlexibleStringExpander toExpand = FlexibleStringExpander.getInstance(serviceName);
ModelService service = null;
try {
service = dispatcher.getDispatchContext().getModelService(toExpand.toString());
} catch (GenericServiceException e) {
Debug.logError("Resolve service throw an error : " + e, module);
}
if (service == null) {
Debug.logError("We can not append auto service Parameters since we could not find service with name [" + serviceName + "]", module);
return autServiceParams;
}
Iterator<ModelParam> paramsIter = service.getInModelParamList().iterator();
if (paramsIter != null) {
while (paramsIter.hasNext()) {
ModelParam param = paramsIter.next();
if (param.getInternal()) continue;
String paramName = param.getName();
FlexibleMapAccessor<Object> fma = FlexibleMapAccessor.getInstance(paramName);
if (!excludeList.contains(paramName)) {
Object flexibleValue = fma.get(context);
if (UtilValidate.isEmpty(flexibleValue) && context.containsKey("parameters")) {
flexibleValue = fma.get((Map<String, ? extends Object>) context.get("parameters"));
}
if (UtilValidate.isNotEmpty(flexibleValue) || sendIfEmpty) {
autServiceParams.put(paramName, String.valueOf(flexibleValue));
}
}
}
}
return autServiceParams;
}
}
public static class AutoEntityParameters {
private String entityName;
private String includeType;
List<String> excludeList = FastList.newInstance();
boolean includePk;
boolean includeNonPk;
boolean sendIfEmpty;
public AutoEntityParameters(Element autoElement){
entityName = UtilXml.checkEmpty(autoElement.getAttribute("entity-name"));
sendIfEmpty = "true".equals(autoElement.getAttribute("send-if-empty"));
includeType = UtilXml.checkEmpty(autoElement.getAttribute("include"));
includePk = "pk".equals(includeType) || "all".equals(includeType);
includeNonPk = "nonpk".equals(includeType) || "all".equals(includeType);
List<? extends Element> excludes = UtilXml.childElementList(autoElement, "exclude");
if (excludes != null) {
for (Element exclude: excludes) {
if (UtilValidate.isNotEmpty(exclude.getAttribute("field-name"))) {
excludeList.add(exclude.getAttribute("field-name"));
}
}
}
}
public Map<String, String> getParametersMap(Map<String, Object> context, String defaultEntityName) {
Map<String, String> autEntityParams = FastMap.newInstance();
Delegator delegator = (Delegator) context.get("delegator");
if (delegator == null) {
Debug.logError("We can not append auto entity Parameters since we could not find delegator in the current context", module);
return autEntityParams;
}
if (UtilValidate.isEmpty(entityName)) entityName = defaultEntityName;
FlexibleStringExpander toExpand = FlexibleStringExpander.getInstance(entityName);
ModelEntity entity = delegator.getModelEntity(toExpand.expandString(context));
if (entity == null) {
Debug.logError("We can not append auto entity Parameters since we could not find entity with name [" + entityName + "]", module);
return autEntityParams;
}
Iterator<ModelField> fieldsIter = entity.getFieldsIterator();
if (fieldsIter != null) {
while (fieldsIter.hasNext()) {
ModelField field = fieldsIter.next();
String fieldName = field.getName();
FlexibleMapAccessor<Object> fma = FlexibleMapAccessor.getInstance(fieldName);
boolean shouldExclude = excludeList.contains(fieldName);
if ((!shouldExclude) && (!field.getIsAutoCreatedInternal())
&& ((field.getIsPk() && includePk) || (!field.getIsPk() && includeNonPk))) {
Object flexibleValue = fma.get(context);
if (UtilValidate.isEmpty(flexibleValue) && context.containsKey("parameters")) {
flexibleValue = fma.get((Map<String, Object>) context.get("parameters"));
}
if (UtilValidate.isNotEmpty(flexibleValue) || sendIfEmpty) {
autEntityParams.put(fieldName, String.valueOf(flexibleValue));
}
}
}
}
return autEntityParams;
}
}
public static String determineAutoLinkType(String linkType, String target, String targetType, HttpServletRequest request) {
if ("auto".equals(linkType)) {
if ("intra-app".equals(targetType)) {
@@ -513,6 +513,9 @@ public class ModelForm extends ModelWidget {
UpdateArea updateArea = new UpdateArea(updateAreaElement);
this.addOnEventUpdateArea(updateArea);
}
//propagate defaultEntityName on updateAreas
if (UtilValidate.isNotEmpty(this.defaultEntityName)) this.setDefaultEntityNameOnUpdateAreas();
if (UtilValidate.isNotEmpty(this.defaultServiceName)) this.setDefaultServiceNameOnUpdateAreas();
// auto-fields-service
for (Element autoFieldsServiceElement: UtilXml.childElementList(formElement, "auto-fields-service")) {
@@ -2814,6 +2817,28 @@ public class ModelForm extends ModelWidget {
return this.onSubmitUpdateAreas;
}
public void setDefaultEntityNameOnUpdateAreas() {
List<UpdateArea> allUpdateAreas = FastList.newInstance();
if (UtilValidate.isNotEmpty(this.onSubmitUpdateAreas)) allUpdateAreas.addAll(this.onSubmitUpdateAreas);
if (UtilValidate.isNotEmpty(this.onPaginateUpdateAreas)) allUpdateAreas.addAll(this.onPaginateUpdateAreas);
for (UpdateArea updateArea : allUpdateAreas) {
if (UtilValidate.isEmpty(updateArea.defaultEntityName)) {
updateArea.defaultEntityName = this.defaultEntityName;
}
}
}
public void setDefaultServiceNameOnUpdateAreas() {
List<UpdateArea> allUpdateAreas = FastList.newInstance();
if (UtilValidate.isNotEmpty(this.onSubmitUpdateAreas)) allUpdateAreas.addAll(this.onSubmitUpdateAreas);
if (UtilValidate.isNotEmpty(this.onPaginateUpdateAreas)) allUpdateAreas.addAll(this.onPaginateUpdateAreas);
for (UpdateArea updateArea : allUpdateAreas) {
if (UtilValidate.isEmpty(updateArea.defaultServiceName)) {
updateArea.defaultServiceName = this.defaultServiceName;
}
}
}
public static class AltRowStyle {
public String useWhen;
public String style;
@@ -2878,7 +2903,11 @@ public class ModelForm extends ModelWidget {
protected String eventType;
protected String areaId;
protected String areaTarget;
List<WidgetWorker.Parameter> parameterList =FastList.newInstance();
protected String defaultServiceName;
protected String defaultEntityName;
protected WidgetWorker.AutoEntityParameters autoEntityParameters;
protected WidgetWorker.AutoEntityParameters autoServiceParameters;
List<WidgetWorker.Parameter> parameterList = FastList.newInstance();
/** XML constructor.
* @param updateAreaElement The <code>&lt;on-xxx-update-area&gt;</code>
* XML element.
@@ -2891,6 +2920,14 @@ public class ModelForm extends ModelWidget {
for (Element parameterElement: parameterElementList) {
this.parameterList.add(new WidgetWorker.Parameter(parameterElement));
}
Element autoServiceParamsElement = UtilXml.firstChildElement(updateAreaElement, "auto-parameters-service");
if (autoServiceParamsElement != null) {
autoServiceParameters = new WidgetWorker.AutoEntityParameters(autoServiceParamsElement);
}
Element autoEntityParamsElement = UtilXml.firstChildElement(updateAreaElement, "auto-parameters-entity");
if (autoEntityParamsElement != null) {
autoEntityParameters = new WidgetWorker.AutoEntityParameters(autoEntityParamsElement);
}
}
/** String constructor.
* @param areaId The id of the widget element to be updated
@@ -2920,10 +2957,16 @@ public class ModelForm extends ModelWidget {
}
public Map<String, String> getParameterMap(Map<String, Object> context) {
Map<String, String> fullParameterMap = FastMap.newInstance();
if (autoServiceParameters != null) {
fullParameterMap.putAll(autoServiceParameters.getParametersMap(context, defaultServiceName));
}
if (autoEntityParameters != null) {
fullParameterMap.putAll(autoEntityParameters.getParametersMap(context, defaultEntityName));
}
for (WidgetWorker.Parameter parameter: this.parameterList) {
fullParameterMap.put(parameter.getName(), parameter.getValue(context));
}
return fullParameterMap;
}
}
@@ -218,13 +218,13 @@ public class ModelFormField {
}
protected void addOnChangeUpdateArea(UpdateArea updateArea) {
if (onChangeUpdateAreas == null) onChangeUpdateAreas = FastList.newInstance();
if (onChangeUpdateAreas == null) onChangeUpdateAreas = FastList.newInstance();
onChangeUpdateAreas.add(updateArea);
Debug.logInfo(this.modelForm.getName() + ":" + this.name + " onChangeUpdateAreas size = " + onChangeUpdateAreas.size(), module);
}
protected void addOnClickUpdateArea(UpdateArea updateArea) {
if (onClickUpdateAreas == null) onClickUpdateAreas = FastList.newInstance();
if (onClickUpdateAreas == null) onClickUpdateAreas = FastList.newInstance();
onClickUpdateAreas.add(updateArea);
}
@@ -2226,6 +2226,8 @@ public class ModelFormField {
protected FlexibleStringExpander targetWindowExdr;
protected FlexibleMapAccessor<Map<String, String>> parametersMapAcsr;
protected List<WidgetWorker.Parameter> parameterList = FastList.newInstance();
protected WidgetWorker.AutoServiceParameters autoServiceParameters;
protected WidgetWorker.AutoEntityParameters autoEntityParameters;
protected boolean requestConfirmation = false;
protected FlexibleStringExpander confirmationMsgExdr;
@@ -2261,6 +2263,14 @@ public class ModelFormField {
for (Element parameterElement: parameterElementList) {
this.parameterList.add(new WidgetWorker.Parameter(parameterElement));
}
Element autoServiceParamsElement = UtilXml.firstChildElement(element, "auto-parameters-service");
if (autoServiceParamsElement != null) {
autoServiceParameters = new WidgetWorker.AutoServiceParameters(autoServiceParamsElement);
}
Element autoEntityParamsElement = UtilXml.firstChildElement(element, "auto-parameters-entity");
if (autoEntityParamsElement != null) {
autoEntityParameters = new WidgetWorker.AutoEntityParameters(autoEntityParamsElement);
}
}
@Override
@@ -2278,8 +2288,8 @@ public class ModelFormField {
public String getConfirmation(Map<String, Object> context) {
String message = getConfirmationMsg(context);
if (UtilValidate.isNotEmpty(message)) return message;
if (UtilValidate.isNotEmpty(message)) return message;
if (getRequestConfirmation()) {
String defaultMessage = UtilProperties.getPropertyValue("general", "default.confirmation.message", "${uiLabelMap.CommonConfirm}");
setConfirmationMsg(defaultMessage);
@@ -2333,11 +2343,19 @@ public class ModelFormField {
if (addlParamMap != null) {
fullParameterMap.putAll(addlParamMap);
}
for (WidgetWorker.Parameter parameter: this.parameterList) {
fullParameterMap.put(parameter.getName(), parameter.getValue(context));
}
if (autoServiceParameters != null) {
fullParameterMap.putAll(autoServiceParameters.getParametersMap(context, this.getModelFormField().getModelForm().getDefaultServiceName()));
}
if (autoEntityParameters != null) {
fullParameterMap.putAll(autoEntityParameters.getParametersMap(context, this.getModelFormField().getModelForm().getDefaultEntityName()));
}
return fullParameterMap;
}
@@ -2419,6 +2437,8 @@ public class ModelFormField {
protected boolean requestConfirmation = false;
protected FlexibleStringExpander confirmationMsgExdr;
protected ModelFormField modelFormField;
protected WidgetWorker.AutoServiceParameters autoServiceParameters;
protected WidgetWorker.AutoEntityParameters autoEntityParameters;
public SubHyperlink(Element element, ModelFormField modelFormField) {
this.setDescription(element.getAttribute("description"));
@@ -2434,7 +2454,14 @@ public class ModelFormField {
}
setRequestConfirmation("true".equals(element.getAttribute("request-confirmation")));
setConfirmationMsg(element.getAttribute("confirmation-message"));
Element autoServiceParamsElement = UtilXml.firstChildElement(element, "auto-parameters-service");
if (autoServiceParamsElement != null) {
autoServiceParameters = new WidgetWorker.AutoServiceParameters(autoServiceParamsElement);
}
Element autoEntityParamsElement = UtilXml.firstChildElement(element, "auto-parameters-entity");
if (autoEntityParamsElement != null) {
autoEntityParameters = new WidgetWorker.AutoEntityParameters(autoEntityParamsElement);
}
this.modelFormField = modelFormField;
}
@@ -2485,7 +2512,14 @@ public class ModelFormField {
for (WidgetWorker.Parameter parameter: this.parameterList) {
fullParameterMap.put(parameter.getName(), parameter.getValue(context));
}
if (autoServiceParameters != null) {
fullParameterMap.putAll(autoServiceParameters.getParametersMap(context, this.getModelFormField().getModelForm().getDefaultServiceName()));
}
if (autoEntityParameters != null) {
fullParameterMap.putAll(autoEntityParameters.getParametersMap(context, this.getModelFormField().getModelForm().getDefaultEntityName()));
}
return fullParameterMap;
}
@@ -578,6 +578,8 @@ public class ModelMenuItem {
protected boolean secure = false;
protected boolean encode = false;
protected String linkType;
protected WidgetWorker.AutoServiceParameters autoServiceParameters;
protected WidgetWorker.AutoEntityParameters autoEntityParameters;
protected FlexibleMapAccessor<Map<String, String>> parametersMapAcsr;
protected List<WidgetWorker.Parameter> parameterList = FastList.newInstance();
protected boolean requestConfirmation = false;
@@ -609,6 +611,14 @@ public class ModelMenuItem {
}
setRequestConfirmation("true".equals(linkElement.getAttribute("request-confirmation")));
setConfirmationMsg(linkElement.getAttribute("confirmation-message"));
Element autoServiceParamsElement = UtilXml.firstChildElement(linkElement, "auto-parameters-service");
if (autoServiceParamsElement != null) {
autoServiceParameters = new WidgetWorker.AutoServiceParameters(autoServiceParamsElement);
}
Element autoEntityParamsElement = UtilXml.firstChildElement(linkElement, "auto-parameters-entity");
if (autoEntityParamsElement != null) {
autoEntityParameters = new WidgetWorker.AutoEntityParameters(autoEntityParamsElement);
}
}
public Link(ModelMenuItem parentMenuItem) {
@@ -716,7 +726,12 @@ public class ModelMenuItem {
for (WidgetWorker.Parameter parameter: this.parameterList) {
fullParameterMap.put(parameter.getName(), parameter.getValue(context));
}
if (autoServiceParameters != null) {
fullParameterMap.putAll(autoServiceParameters.getParametersMap(context, null));
}
if (autoEntityParameters != null) {
fullParameterMap.putAll(autoEntityParameters.getParametersMap(context, linkMenuItem.getModelMenu().getDefaultEntityName()));
}
return fullParameterMap;
}
@@ -1387,7 +1387,8 @@ public abstract class ModelScreenWidget extends ModelWidget {
protected String width;
protected String height;
protected List<WidgetWorker.Parameter> parameterList = FastList.newInstance();
protected WidgetWorker.AutoServiceParameters autoServiceParameters;
protected WidgetWorker.AutoEntityParameters autoEntityParameters;
public Link(ModelScreen modelScreen, Element linkElement) {
super(modelScreen, linkElement);
@@ -1414,6 +1415,15 @@ public abstract class ModelScreenWidget extends ModelWidget {
this.parameterList.add(new WidgetWorker.Parameter(parameterElement));
}
Element autoServiceParamsElement = UtilXml.firstChildElement(linkElement, "auto-parameters-service");
if (autoServiceParamsElement != null) {
autoServiceParameters = new WidgetWorker.AutoServiceParameters(autoServiceParamsElement);
}
Element autoEntityParamsElement = UtilXml.firstChildElement(linkElement, "auto-parameters-entity");
if (autoEntityParamsElement != null) {
autoEntityParameters = new WidgetWorker.AutoEntityParameters(autoEntityParamsElement);
}
this.width = linkElement.getAttribute("width");
this.height = linkElement.getAttribute("height");
}
@@ -1512,7 +1522,14 @@ public abstract class ModelScreenWidget extends ModelWidget {
for (WidgetWorker.Parameter parameter: this.parameterList) {
fullParameterMap.put(parameter.getName(), parameter.getValue(context));
}
if (autoServiceParameters != null) {
fullParameterMap.putAll(autoServiceParameters.getParametersMap(context, null));
}
if (autoEntityParameters != null) {
fullParameterMap.putAll(autoEntityParameters.getParametersMap(context, null));
}
return fullParameterMap;
}