My common usecase for my Struts2 application is that I have Actions that collect data which are presented on an JSP page. I'll call these view-actions.
But then I also have logic actions, which "do" something in the background (like registering a user). These might also have a bean that needs to be shown on an JSP, but I need to redirect the result to one of the view-actions.
Sadly, the bean I need from the first action doesn't get transferred to the ValueStack, but only values from getters from the view action. Example:
<action name="mailConfirm" class="de.abelssoft.updateyeti.Frontend.MailConfirmer">
<result name="login" type="redirectAction">
<param name="actionName">register</param>
<param name="email">${person.email}</param>
</resul开发者_StackOverflowt>
<result name="input" type="redirectAction">
<param name="actionName">register</param>
</result>
</action>
What is the pattern I'm missing here? Or do I have to store everything I need in the response context?
I got no answer to this question, so I'll tell you what I've done. Sorry for not providing a "good answer".
I wrote two interceptors. One for the logical action that would store message-objects in the user session temporarily and one for my view actions that would take and remove them out of the usersession.
I used the logical action interceptor where needed and used the viewaction interceptor for all other action to make sure that when an action redirection has happened before the view action, the message-objects will be found and used.
精彩评论