FEATURE: When calling services from an incoming http requests, allow for a different request and session attribute name to be specified.
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1482508 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -401,6 +401,8 @@ under the License.
|
||||
<xs:attribute name="form-label" type="xs:string"/>
|
||||
<xs:attribute name="entity-name" type="xs:string"/>
|
||||
<xs:attribute name="field-name" type="xs:string"/>
|
||||
<xs:attribute name="request-attribute-name" type="xs:string"/>
|
||||
<xs:attribute name="session-attribute-name" type="xs:string"/>
|
||||
<xs:attribute name="string-map-prefix" type="xs:string"/>
|
||||
<xs:attribute name="string-list-suffix" type="xs:string"/>
|
||||
<xs:attribute name="form-display" default="true">
|
||||
|
||||
@@ -61,6 +61,12 @@ public class ModelParam implements Serializable {
|
||||
/** The entity field name */
|
||||
public String fieldName;
|
||||
|
||||
/** Request attribute to look for if not defined as a parameter */
|
||||
public String requestAttributeName;
|
||||
|
||||
/** Session attribute to look for if not defined as a parameter */
|
||||
public String sessionAttributeName;
|
||||
|
||||
/** Parameter prefix for creating an attribute Map */
|
||||
public String stringMapPrefix;
|
||||
|
||||
@@ -97,6 +103,8 @@ public class ModelParam implements Serializable {
|
||||
this.formLabel = param.formLabel;
|
||||
this.entityName = param.entityName;
|
||||
this.fieldName = param.fieldName;
|
||||
this.requestAttributeName = param.requestAttributeName;
|
||||
this.sessionAttributeName = param.sessionAttributeName;
|
||||
this.stringMapPrefix = param.stringMapPrefix;
|
||||
this.stringListSuffix = param.stringListSuffix;
|
||||
this.validators = param.validators;
|
||||
|
||||
@@ -504,6 +504,8 @@ public class ModelServiceReader implements Serializable {
|
||||
param.mode = UtilXml.checkEmpty(attribute.getAttribute("mode")).intern();
|
||||
param.entityName = UtilXml.checkEmpty(attribute.getAttribute("entity-name")).intern();
|
||||
param.fieldName = UtilXml.checkEmpty(attribute.getAttribute("field-name")).intern();
|
||||
param.requestAttributeName = UtilXml.checkEmpty(attribute.getAttribute("request-attribute-name")).intern();
|
||||
param.sessionAttributeName = UtilXml.checkEmpty(attribute.getAttribute("session-attribute-name")).intern();
|
||||
param.stringMapPrefix = UtilXml.checkEmpty(attribute.getAttribute("string-map-prefix")).intern();
|
||||
param.stringListSuffix = UtilXml.checkEmpty(attribute.getAttribute("string-list-suffix")).intern();
|
||||
param.formLabel = attribute.hasAttribute("form-label")?attribute.getAttribute("form-label").intern():null;
|
||||
|
||||
@@ -257,7 +257,7 @@ public class ServiceEventHandler implements EventHandler {
|
||||
|
||||
// next check attributes; do this before parameters so that attribute which can be changed by code can override parameters which can't
|
||||
if (UtilValidate.isEmpty(value)) {
|
||||
Object tempVal = request.getAttribute(name);
|
||||
Object tempVal = request.getAttribute(UtilValidate.isEmpty(modelParam.requestAttributeName) ? name : modelParam.requestAttributeName);
|
||||
if (tempVal != null) {
|
||||
value = tempVal;
|
||||
}
|
||||
@@ -283,7 +283,7 @@ public class ServiceEventHandler implements EventHandler {
|
||||
|
||||
// then session
|
||||
if (UtilValidate.isEmpty(value)) {
|
||||
Object tempVal = request.getSession().getAttribute(name);
|
||||
Object tempVal = request.getSession().getAttribute(UtilValidate.isEmpty(modelParam.sessionAttributeName) ? name : modelParam.sessionAttributeName);
|
||||
if (tempVal != null) {
|
||||
value = tempVal;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user