Pre populating a form
1 posts in topic
Flat View  Flat View

Posted By:   Tommy_Tucker
Posted On:   Wednesday, May 21, 2003 04:45 AM

I have a page where a new user or an existing user can access

to get to this page the user get's a choice to enter a new user name or an existing user

the user is then forwarded on to a page where he can enter details.

my problem is that if the user is an exixting user i want to enter his previous details in the fields of the form.

anyone have any idea how i would do this?

thanks in advance tommy

Re: Pre populating a form

Posted By:   Christopher_Koenigsberg  
Posted On:   Wednesday, May 21, 2003 07:00 AM

I do it in the "reset" method of the ActionForm subclass (e.g. your "enter details" form). It checks for a "prefill" attribute in the request (e.g. a bean containing the values, of the properties for the existing user). If present, it uses that to prefill the properties in the new form. Otherwise it resets them all to null, as usual.

So, the previous Action (e.g. your "enter username") is responsible, for setting this "prefill" bean (with the properties for an existing user, if entered) at the request scope attribute, before returning the action mapping to forward to the jsp for entering details.

About | Sitemap | Contact