My input page doesnt seem to be retaining the values
when the Action class does the forward back to the
input.
Prob2: I use ActionErros class and I add erros I
encounter in the Action class to the ActionErros. And
in the input page I use <strus:errors/> tag. But the
error messages arent getting displayed. What could be
the reason.
And thanks for the earlier reply.
--- "Craig R. McClanahan"
<[EMAIL PROTECTED]> wrote:
> John Hunt wrote:
> 
> > Hi
> > Suppose I have an ActionForm class for some
> validation
> > stuff and after that the associated Action class
> does
> > some more validation....
> > If ActionForm class validation fails then the
> request
> > is forwarded back to the input page  and the page
> is
> > redisplayed and the whatever data the user has
> input
> > would be displayed. ( I mean struts does that )
> > But if it is the ActionClass which did some
> validation
> > and on failure if it forwards the request to the
> > inputForm, then I am losing all the data which the
> > user has input. In such scenarios what needs to be
> > done???
> >
> 
> The Struts example application actually does exactly
> this -- for example, in
> SaveRegistrationAction there is an extra check that
> the specified username is
> unique when you are creating a new user.  It uses
> logic like this:
> 
>     ActionErrors errors = new ActionErrors();
>     ... check for additional errors ...
>     ... and add them to the "errors" object ...
>     if (!errors.empty()) {
>         saveErrors(request, errors);
>         return (new
> ActionForward(mapping.getInput()));
>     }
> 
> > To summarise, my question is if Action class does
> > validation and redirects to the input page because
> of
> > errors, how can I retain the values which the user
> has
> > input before.
> >
> 
> No, the input data is not lost.  The reason is that
> control is being returned to
> the input form with a RequestDispatcher.forward(),
> and the form bean is still
> present as a request or session attribute (depending
> on which mechanism you
> chose).  Therefore, when the input page is
> redisplayed, the current form values
> will already be there -- just as if you were
> processing errors caught by the
> validate() method.
> 
> Craig McClanahan
> 
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices. 
http://auctions.yahoo.com/

Reply via email to