One way would be to pass a hidden parameter that tells you which page you
came from.
In page1.jsp form you could add:
   <s:hidden name="page" value="page1" />
You would need to add a setter and getter in you action for page variable.
Then your result could be:
   <result name="input">/WEB-INF/pages/${page}.jsp</result>

Another way would to have different actions defined for each page so they
know where to return to:

<action name="MyActionPage1" class="MyAction">
   <result name="page1">/WEB-INF/pages/page1.jsp</result>
  <result name="page2">/WEB-INF/pages/page2.jsp</result>
  <result name="input">/WEB-INF/pages/page1.jsp</result>
</action>
<action name="MyActionPage2" class="MyAction">
   <result name="page1">/WEB-INF/pages/page1.jsp</result>
  <result name="page2">/WEB-INF/pages/page2.jsp</result>
  <result name="input">/WEB-INF/pages/page2.jsp</result>
</action>

On Wed, Jul 8, 2009 at 4:05 AM, <mailtolouis2020-str...@yahoo.com> wrote:

> 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

Reply via email to