« Return to Thread: Struts 2 Validation

dynamic return when validation failed

by mailtolouis2020-struts :: Rate this Message:

Reply to Author | View in Thread

Hello,

I'm new to struts2, and learning the validation in struts 2 at the moment.

I'm not able to get the validation work in the way I want in the webflow (or wizard kind of page) design. Everytime when validation failed, it always return to INPUT page, I wondering is there a way I can tell struts return to different result page depand on what validation failed.

For e.g, I got page1.jsp, page2.jsp both are calling the same action, when page1 submit and the validation failed, I want it to go back to page1, if page2 submit I want to control it to go back to page2  if the validation fail.

What I can possible think of the solutions right now is write my own custom validation interceptor which allow to dynamic set where to return.

Another solution I'm not sure whether I can achive or not, for e.g below is the configuration of my action


<action name="MyAction" class="MyAction">
<result name="page1">/WEB-INF/pages/page1.jsp</result>
<result name="page2">/WEB-INF/pages/page2.jsp</result>
<result name="input">${input}</result>
</action>
       
In the action I want to get the value of result name="page1" or "page2", is it possible? If so then I can pass it to ${input}

Or is there any other better way to solve this?


Regards
Louis

 « Return to Thread: Struts 2 Validation