You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Adam Crume (JIRA)" <ji...@apache.org> on 2007/05/18 16:49:43 UTC
[jira] Commented: (WW-1027) ValidationInterceptor and
DefaultWorkflowInterceptor Improvements for forwarding to another action
when meeting validation error
[ https://issues.apache.org/struts/browse/WW-1027?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_41015 ]
Adam Crume commented on WW-1027:
--------------------------------
I believe this *is* an issue. I have an action saveAction which I want to chain to editAction whenever there is a validation error. This is often necessary because a JSP will be displayed which has dynamic content such as a selectable list of items. However, if editAction has validation support, it will never be executed (even if it would validate successfully).
> ValidationInterceptor and DefaultWorkflowInterceptor Improvements for forwarding to another action when meeting validation error
> --------------------------------------------------------------------------------------------------------------------------------
>
> Key: WW-1027
> URL: https://issues.apache.org/struts/browse/WW-1027
> Project: Struts 2
> Issue Type: Improvement
> Affects Versions: WW 2.2
> Environment: jdk: sun jdk 1.4.2 appserver: tomcat 4.1.28 os:windows xp sp2
> Reporter: jacky hua
> Assigned To: Rene Gielen
> Fix For: WW 2.2.1
>
>
> when meeting validation error after submitting a page, the program will go into DefaultWorkflowInterceptor and return fixed result code:"input", the result code is pointed to a jsp or an action according to the defination of xwork.xml, and I think pointing to an action is powerful choice, because it can give a chance to prepare some data for last display page. so this action must escape from validation, since it already has a validation error information. so I suggest to add a specific flag indicating this action can escape from validation. some modified code of DefaultWorkflowInterceptor is like below:
> public String intercept(ActionInvocation invocation) throws Exception {
> final ActionContext context = invocation.getInvocationContext();
> HttpServletRequest request = (HttpServletRequest) context.get(HTTP_REQUEST);
> Boolean isEscape = (Boolean)request.getAttribute("webwork.validation.escape");
> if (isEscape != null && isEscape.booleanValue()) {
> log.debug("Skipping workflow. Validation escape flag found in request.");
> return invocation.invoke();
> }
>
> if (excludeMethods.contains(invocation.getProxy().getMethod())) {
> log.debug("Skipping workflow. Method found in exclude list.");
> return invocation.invoke();
> }
> Object action = invocation.getAction();
> if (action instanceof Validateable) {
> Validateable validateable = (Validateable) action;
> validateable.validate();
> }
> if (action instanceof ValidationAware) {
> ValidationAware validationAwareAction = (ValidationAware) action;
> if (validationAwareAction.hasErrors()) {
> request.setAttribute("webwork.validation.escape", new Boolean(true));
> return Action.INPUT;
> }
> }
> return invocation.invoke();
> }
> in addition we need modify ValidationInterceptor similar with above for completelly escaping, code like:
> protected void before(ActionInvocation invocation) throws Exception {
> final ActionContext context = invocation.getInvocationContext();
> HttpServletRequest request = (HttpServletRequest) context.get(HTTP_REQUEST);
> Boolean isEscape = (Boolean)request.getAttribute("webwork.validation.escape");
> if (isEscape != null && isEscape.booleanValue()) {
> log.debug("Skipping workflow. Validation escape flag found in request.");
> return invocation.invoke();
> }
> if (excludeMethods.contains(invocation.getProxy().getMethod())) {
> log.debug("Skipping validation. Method found in exclude list.");
> return;
> }
> Object action = invocation.getAction();
> String context = invocation.getProxy().getActionName();
> if (log.isDebugEnabled()) {
> log.debug("Validating "
> + invocation.getProxy().getNamespace() + "/" + invocation.getProxy().getActionName() + ".");
> }
> ActionValidatorManagerFactory.getInstance().validate(action, context);
> }
> This feature is similar with these two interceptores excludeMethods property, but different action has different exclude methods list, it will result in a messy xwork.xml, so I recommend this solution. any other sugguestion?
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.