You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by flare <fl...@flare.it> on 2001/07/09 18:08:57 UTC

form population from database

that's a classic portal problem, I've built a container based form 
autentication, the user log in then can edit his profile, I want to 
use the same ActionClass I use for registration so I have a link that 
points to:    
myActionClass.do?action=edit
inside the actionclass I've a bean that (when action=edit) fetches 
the user data from a db then populate the actionform and points back 
to the input form.
The problem is that when the framework instantiates the actionform 
(since it doesn't exist), it fills the action field bean and 
suddendly calls the validate method so I got an error page instead of 
the populated edit form!   
Which is the correct way to handle this? 


 Fla' 


Re: form population from database

Posted by Ted Husted <hu...@apache.org>.
One approach is to have more than one ActionMapping leading to the same
Action. To instatiate the form, use a mapping with validate=false, to
insert or update the form, use a mapping with validate=true. 

So you might have one mapping to "myActionClass" (with validate false)
and another to "myActionClassSave" (with validate true), but both would
point to the same myActionClass.

I believe the example application does something like this.

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 737-3463.
-- http://www.husted.com/about/struts/

flare wrote:
> 
> that's a classic portal problem, I've built a container based form
> autentication, the user log in then can edit his profile, I want to
> use the same ActionClass I use for registration so I have a link that
> points to:
> myActionClass.do?action=edit
> inside the actionclass I've a bean that (when action=edit) fetches
> the user data from a db then populate the actionform and points back
> to the input form.
> The problem is that when the framework instantiates the actionform
> (since it doesn't exist), it fills the action field bean and
> suddendly calls the validate method so I got an error page instead of
> the populated edit form!
> Which is the correct way to handle this?
> 
>  Fla'