Reputation: 487
I have been reading about the StoreInterceptor
in the Struts 2 docs, and it talks about how to stick the StoreInterceptor
in your Action
definition in your struts-config.xml
, and it just works. But that is, if you are creating and adding the ActionErrors
from within the Action
.
My problem is that I am doing a Login
using a LoginInterceptor
which, if the Login
fails, adds an ActionError
like so:
((ActionSupport) invocation.getAction()).addActionError("Login failed");
It's added just fine, but when I get to the LoginAction
, which is invoked after the LoginInterceptor
, ValidationAwareSupport.actionErrors
is null
.
I thought that by adding the StoreInterceptor
like this, it would store the ActionErrors
, either in request or session (using the operationMode
"store"
or "retreive"
parameter):
<action name="login" class="...LoginFormAction" >
<interceptor-ref name="store">
<param name="operationMode">store</param>
</interceptor-ref>
<interceptor-ref name="defaultStack" />
<result name="input" type="tiles">adminLogin</result>
<result name="success" type="tiles">adminLogin</result>
</action>
But, it's not working. I've also tried adding the StoreInterceptor
directly to the defaultStack
, that doesn't work either.
Does StoreInterceptor
work not just for saving ActionErrors
between actions, but also between interceptors and actions?
Upvotes: 0
Views: 1332
Reputation: 1
The store
interceptor works between two actions, one of them store the messages, another retrieve them.
In you configuration you have only one action. The second action should be configured to retrieve messages.
The store
interceptor doesn't work between action and interceptor or between interceptors.
Upvotes: 0