问题
I have 2 actions. First to display form and another to process form. If processAdd
action is not validated than redirectAction back to Add
action. Store
interceptor shows proper errors on the "Add" action but filled in values on the form are lost during redirect action.
I loose Value Stack
on redirection, I understand that.
Is there any solution to this?
Don't want to use result param, too much work.
<action name="add" class="com.myapp.actions.StudentAction" method="input">
<interceptor-ref name="store">
<param name="operationMode">RETRIEVE</param>
</interceptor-ref>
<result name="input" type="tiles">/student.edit.tiles</result>
</action>
<action name="processAdd" class="com.myapp.actions.StudentAction">
<interceptor-ref name="store">
<param name="operationMode">STORE</param>
</interceptor-ref>
<interceptor-ref name="defaultStack" />
<result name="success" type="redirectAction">list</result>
<result name="input" type="redirectAction">add</result>
<result name="failure" type="redirectAction">add</result>
</action>
回答1:
What you're looking for is the Scope Interceptor, not the Store Interceptor.
回答2:
MessageStoreInterceptor
An interceptor to store a ValidationAware action's messages / errors and field errors into HTTP Session, such that it will be retrieveable at a later stage. This allows the action's message / errors and field errors to be available longer that just the particular HTTP request.
You can't get the value stack data using message store interceptor it care's about action messages / errors and field errors.
Alternatively you can use chain interceptor or store values in session even message store interceptor uses session object to store message / errors.
来源:https://stackoverflow.com/questions/12773877/store-interceptor-and-loose-value-stack-when-redirection