if u have overridden validate method in the actionForm then ActionServlet
automatically take u to the mapping.getInput() ( i.e  ur input jsp file )
where u can show the errors using <html:errors> tag . Basicallly
ActionErrors are kept in the request scope which are retrieved in the
<html:errors> tag

Else if u want to do validation even in ur action class , then create a
instance of ActionErrors in the action class and add errors to it . save the
errors using saveErrors(request , actionErrros) method available in the
Struts- Action class . So errors will be kept in the request scope and again
use same <html:errors> tag to display them

For both editUser and save saveUser use same actionForm
Suhas


----- Original Message -----
From: Aapo Laakkonen <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 25, 2001 2:32 PM
Subject: Pre-Populating ActionForm (again)


> I know that this have been asked several times, but I did
> not find answer for this little problem.
>
> I have list of lets say users. Each user has a link that maps
> to edituser action. That action then gets executed and it
> places userbean to request scope. Then struts forwards
> action to edituser.jsp. Edituser.jsp has form that has
> action mapping set to updateuser. When user submits
> that form which binds to userform action form the
> validate method of that actionform gets executed. If
> validation errors occurred then we get back to input
> form (which is edituser.jsp or edituser.do <-- which
> to use?). And this is the point when I do not really
> understand what I should do, because when user gets
> back to edituser.jsp or edituser.do then there is not
> anymore that userbean is request scope. And because
> edituser.do does not have any forms associated with
> it then I should instead use edituser.jsp as input for
> updateuser action. But how I then write that form
> (jsp-page)?
>
> I have several options:
>
> 1. put userbean in session scope (might be problem in
> multiserver environment also the modifications that user
> entered are not visible).
>
> 2. Have another jsp-page that does not populate the form
> from userbean. Not good option because almost the same
> form needs to be written second time.
>
> 3. Use logic tags to check the existence of userbean and if
> it does not exist then do not populate and let the form
> populate itself from posted form. Same problems as in 2.
>
> 4. Somehow prepopulate the form with no manual
> population, but automatically. So do I pre-populate the
> form. What code I need to put in edituser action that
> previously placed userbean in request scope. I want to
> place the form object in that same scope, but don't
> know how. This is the best option and has no problems
> or at least I have not found a one.
>
> Thanks again!
>
> Aapo Laakkonen
>
> -- Aapo Laakkonen, +358 (50) 33 99 682, ProjectCast Ltd, Helsinki,
Finland.
>

Reply via email to