if (actionMessages != null && actionMessages.size() > 0) { for (String message : actionMessages) { validationAware.addActionMessage(message);
if (actionMessages != null && actionMessages.size() > 0) { for (String message : actionMessages) { validationAware.addActionMessage(message);
public String intercept(ActionInvocation invocation) throws Exception { Object action = invocation.getAction(); if (action instanceof ValidationAware) { ValidationAware validationAware = (ValidationAware) action; validationAware.addFieldError("field", "field error"); validationAware.addActionMessage("action message"); validationAware.addActionError("action error"); } return invocation.invoke(); }
@Override protected String handleInvalidToken(ActionInvocation invocation) throws Exception { Object action = invocation.getAction(); String errorMessage = this.getCustomMessage(invocation, "struts.messages.invalid.token", "The form has already been processed or no token was supplied, please try again."); String message = this.getCustomMessage(invocation, "struts.messages.invalid.token.message", "Stop double-submission of forms."); if (action instanceof ValidationAware) { if (null == this.getTypeMessages() || this.getTypeMessages().equalsIgnoreCase(TYPE_RETURN_NONE_MESSAGE)) { //nothing to do } else if (this.getTypeMessages().equalsIgnoreCase(TYPE_RETURN_ACTION_ERROR_MESSAGE)) { ((ValidationAware) action).addActionError(errorMessage); } else if (this.getTypeMessages().equalsIgnoreCase(TYPE_RETURN_ACTION_MESSAGE)) { ((ValidationAware) action).addActionMessage(message); } else { LOG.warn("Invalid message type : {}", this.getTypeMessages()); } } else { LOG.warn(errorMessage); } return INVALID_TOKEN_CODE; }
@Override protected String handleInvalidToken(ActionInvocation invocation) throws Exception { Object action = invocation.getAction(); String errorMessage = this.getCustomMessage(invocation, "struts.messages.invalid.token", "The form has already been processed or no token was supplied, please try again."); String message = this.getCustomMessage(invocation, "struts.messages.invalid.token.message", "Stop double-submission of forms."); if (action instanceof ValidationAware) { if (null == this.getTypeMessages() || this.getTypeMessages().equalsIgnoreCase(TYPE_RETURN_NONE_MESSAGE)) { //nothing to do } else if (this.getTypeMessages().equalsIgnoreCase(TYPE_RETURN_ACTION_ERROR_MESSAGE)) { ((ValidationAware) action).addActionError(errorMessage); } else if (this.getTypeMessages().equalsIgnoreCase(TYPE_RETURN_ACTION_MESSAGE)) { ((ValidationAware) action).addActionMessage(message); } else { LOG.warn("Invalid message type : {}", this.getTypeMessages()); } } else { LOG.warn(errorMessage); } return INVALID_TOKEN_CODE; }