There is nothing in a request that will tell you which page you came from unless you put it there (as with the hidden parameter).
If you don't like that then use the multiple actions so the action name tells you where the request came from (and where to go back). On Wed, Jul 8, 2009 at 11:05 AM, <mailtolouis2020-str...@yahoo.com> wrote: > Hi, > > Thanks for the reply, I try not to hardcode any file name in the jsp, > prefer to put it in the struts config file, but don't know how to get the > value out of it. > > > > Regards > Louis > > > > ________________________________ > From: Greg Lindholm <greg.lindh...@gmail.com> > To: Struts Users Mailing List <user@struts.apache.org> > Sent: Wednesday, July 8, 2009 2:46:00 PM > Subject: Re: dynamic return when validation failed > > 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 >