ActionSupport, defaultStack and xml validation combo doesn't work on subsequent
submits
---------------------------------------------------------------------------------------
Key: WW-2818
URL: https://issues.apache.org/struts/browse/WW-2818
Project: Struts 2
Issue Type: Bug
Components: Core Actions, Core Interceptors
Affects Versions: 2.1.2
Environment: struts 2.1.2, xwork 2.1.1
Reporter: james baker
When you have an action that extends ActionSupport any errors are persisted
forever and cannot be corrected.
Scenario: -
1. Submit form leaving required field blank
2. AnnotationValidationInterceptor picks this up and adds action errors.
3. DefaultWorkflowInterceptor sees there are errors and is instanceof
ValidationAware (from ActionSupport) so returns input without bothering your
action.
4. Fill in required field and re submit.
5. Get the same error! Wuh?
This seems to happen because of the following: -
DefaultActionInvocation init() creates an ActionContext which contains all the
fields on the Action.
createAction() puts everything from ActionContext back on the Action.
One of the fields inherited from ActionSupport is validationAware which gets
set here.
At no point in the default interceptor stack (nor can i see in any of the
provided interceptors) is validationAware reset which means the action errors
and messages stay there.
AnnotationValidationInterceptor doesn't add any more errors.
When you reach the DefaultWorkflowInterceptor it stops you from proceeding
because errors exist (from the previous submit)
You can never get in to your action to reset the errors so what are you
supposed to do.
If you take out the workflow inteceptor you will have to manually check for
action errors added by the validation inteceptor.
You can't clear errors in validate() on your action because xmls are parsed
first.
This has stumped me for now (will probably add my own inteceptor to reset
messages on ValidationAware actions)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.