> -----Original Message----- > From: news [mailto:[EMAIL PROTECTED] On Behalf Of Laurie Harper > Sent: Sunday, September 18, 2005 7:26 PM > To: user@struts.apache.org > Subject: Re: Validator woes, modifying the input forward on the fly? > > David Erickson wrote: > > Hi I have a situation like this: > > User clicks on /viewUser.do?id=4 action, which loads the specific user > with > > id4 to be viewed. > > On that page is a form, the form is submitted, if some part of the xml > > validation fails I need to return back to /viewUser.do?id=4. It would > be > > ideal if the information from the form could be retained. I can set my > > input forward to be: input="/viewUser.do" but somehow I need to access > that > > and add the parameter id=4 to it after the xml validation takes place, > but > > before the new page is requested. Is there any possible way to do this? > > The parameter is stored into the request when it is first submitted, so > provided you haven't told Struts to redirect to the input page (it'll > use a forward by default) the parameter -- and any others submitted from > your form -- should still be in the request. So, you shouldn't need to > do anything yourself to have the data available when the input page is > redisplayed.
I guess a better explanation is due. Ok the user sees /viewUser.do?id=4 which in my action pulls the User object with ID 4 from the db, places it in to the request, then loads the .viewUser tiles definition and displays the data. In that page is a form that submits to /addEmailAddress.do. If the xml validation fails on submitting it then pulls the input forward from addEmailAddress.do, which I tried setting to input=".viewUser", the tiles definition. After a failure validating, my jsp reports an error finding the user object, because when you submit you are getting a new request, and the user object is no longer loaded into the request object. I also tried setting the input element to be input="/viewUser.do", which runs the action again, but doesn't have the id=4 parameter I need to specify which user object to load out of the database. Make sense? So essentially what I am looking for is a way to modify the input forward that is used when validation fails. I tried this in the validate method of my form, however it says configuration locked if I do a setInput(), and if I do getInputForward then modify it, it doesn't seem to do anything.. (probably returning a copy). So.. if anyone has any ideas.. :) Thanks, David --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]