Methods Summary |
---|
protected void | after(com.opensymphony.xwork2.ActionInvocation invocation, java.lang.String result)Handle the storing of field errors / action messages / field errors, which is
done after action invocation, and the operationMode is in 'STORE'.
String reqOperationMode = getRequestOperationMode(invocation);
if (STORE_MODE.equalsIgnoreCase(reqOperationMode) ||
STORE_MODE.equalsIgnoreCase(operationMode)) {
Object action = invocation.getAction();
if (action instanceof ValidationAware) {
// store error / messages into session
Map session = (Map) invocation.getInvocationContext().get(ActionContext.SESSION);
_log.debug("store action ["+action+"] error/messages into session ");
ValidationAware validationAwareAction = (ValidationAware) action;
session.put(actionErrorsSessionKey, validationAwareAction.getActionErrors());
session.put(actionMessagesSessionKey, validationAwareAction.getActionMessages());
session.put(fieldErrorsSessionKey, validationAwareAction.getFieldErrors());
}
else {
_log.debug("Action ["+action+"] is not ValidationAware, no message / error that are storeable");
}
}
|
protected void | before(com.opensymphony.xwork2.ActionInvocation invocation)Handle the retrieving of field errors / action messages / field errors, which is
done before action invocation, and the operationMode is 'RETRIEVE'.
String reqOperationMode = getRequestOperationMode(invocation);
if (RETRIEVE_MODE.equalsIgnoreCase(reqOperationMode) ||
RETRIEVE_MODE.equalsIgnoreCase(operationMode)) {
Object action = invocation.getAction();
if (action instanceof ValidationAware) {
// retrieve error / message from session
Map session = (Map) invocation.getInvocationContext().get(ActionContext.SESSION);
ValidationAware validationAwareAction = (ValidationAware) action;
_log.debug("retrieve error / message from session to populate into action ["+action+"]");
Collection actionErrors = (Collection) session.get(actionErrorsSessionKey);
Collection actionMessages = (Collection) session.get(actionMessagesSessionKey);
Map fieldErrors = (Map) session.get(fieldErrorsSessionKey);
if (actionErrors != null && actionErrors.size() > 0) {
Collection mergedActionErrors = mergeCollection(validationAwareAction.getActionErrors(), actionErrors);
validationAwareAction.setActionErrors(mergedActionErrors);
}
if (actionMessages != null && actionMessages.size() > 0) {
Collection mergedActionMessages = mergeCollection(validationAwareAction.getActionMessages(), actionMessages);
validationAwareAction.setActionMessages(mergedActionMessages);
}
if (fieldErrors != null && fieldErrors.size() > 0) {
Map mergedFieldErrors = mergeMap(validationAwareAction.getFieldErrors(), fieldErrors);
validationAwareAction.setFieldErrors(mergedFieldErrors);
}
session.remove(actionErrorsSessionKey);
session.remove(actionMessagesSessionKey);
session.remove(fieldErrorsSessionKey);
}
}
|
public void | destroy()
|
public boolean | getAllowRequestParameterSwitch()
return this.allowRequestParameterSwitch;
|
public java.lang.String | getOperationModel()
return this.operationMode;
|
protected java.lang.String | getRequestOperationMode(com.opensymphony.xwork2.ActionInvocation invocation)Get the operationMode through request paramter, if allowRequestParameterSwitch
is 'true', else it simply returns 'NONE', meaning its neither in the 'STORE_MODE' nor
'RETRIEVE_MODE'.
String reqOperationMode = NONE;
if (allowRequestParameterSwitch) {
Map reqParams = (Map) invocation.getInvocationContext().get(ActionContext.PARAMETERS);
boolean containsParameter = reqParams.containsKey(requestParameterSwitch);
if (containsParameter) {
String[] reqParamsArr = (String[]) reqParams.get(requestParameterSwitch);
if (reqParamsArr != null && reqParamsArr.length > 0) {
reqOperationMode = reqParamsArr[0];
}
}
}
return reqOperationMode;
|
public java.lang.String | getRequestParameterSwitch()
return this.requestParameterSwitch;
|
public void | init()
|
public java.lang.String | intercept(com.opensymphony.xwork2.ActionInvocation invocation)
_log.debug("entering MessageStoreInterceptor ...");
before(invocation);
String result = invocation.invoke();
after(invocation, result);
_log.debug("exit executing MessageStoreInterceptor");
return result;
|
protected java.util.Collection | mergeCollection(java.util.Collection col1, java.util.Collection col2)Merge col1 and col2 and return the composite
Collection .
Collection _col1 = (col1 == null ? new ArrayList() : col1);
Collection _col2 = (col2 == null ? new ArrayList() : col2);
_col1.addAll(_col2);
return _col1;
|
protected java.util.Map | mergeMap(java.util.Map map1, java.util.Map map2)Merge map1 and map2 and return the composite
Map
Map _map1 = (map1 == null ? new LinkedHashMap() : map1);
Map _map2 = (map2 == null ? new LinkedHashMap() : map2);
_map1.putAll(_map2);
return _map1;
|
public void | setAllowRequestParameterSwitch(boolean allowRequestParameterSwitch)
this.allowRequestParameterSwitch = allowRequestParameterSwitch;
|
public void | setOperationMode(java.lang.String operationMode)
this.operationMode = operationMode;
|
public void | setRequestParameterSwitch(java.lang.String requestParameterSwitch)
this.requestParameterSwitch = requestParameterSwitch;
|