I would use your setter methods to initialize the bean in the reset method rather then 
removing it from scope. 

We have several forms which we pre-populate from a single-sign-on database so that the 
user does not have to type in their name, address etc. We have one action that 
displays the form and another that processes it (sometimes they are the same action 
class, with different parameters.) When the Action to display the form is called we 
use the setter methods in the form bean's reset() to get data from the DB and then 
display it.

-Devin
 


-----Original Message-----
From: deepank [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 26, 2002 9:29 AM
To: Struts Users Mailing List
Subject: Re: initilaizing form bean values


I dont know how  this will help.
I have a form with several records, i have an edit buuton for each record.
If a user cliks the edit button i go back to the action class.
here i would like to pick up data from the database, this data i want to
display in the fields of the form(JSP) for the user to edit.
i have this code in the action as usual

if (mapping.getAttribute() != null) {
     if ("request".equals(mapping.getScope()))
      request.removeAttribute(mapping.getAttribute());
     else
      session.removeAttribute(mapping.getAttribute());
   }


this removes the previous form bean instance. SHOULD I REMOVE THIS CODE and
use setter methods to prepopulate the form bean fields
in the action class.

Deepank


----- Original Message -----
From: "Richards, Devin N (Devin)" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Thursday, September 26, 2002 6:42 PM
Subject: RE: initilaizing form bean values


> Use the form's reset() method (as described in the docs and examples)
>
> -Devin
>
>
> -----Original Message-----
> From: deepank [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 26, 2002 9:16 AM
> To: Struts Users Mailing List
> Subject: initilaizing form bean values
>
>
> hi,
>
> i have form bean for which i would like to initialize some fields with
values before displaying the jsp.
>
> for example if i have something like this in my jsp, how can i initialize
this input field from my Action class with a value that i get from the
database
>
>
> <html:text property="mail_id" />, this should display some initial data
>
> any help will be apprecaited
>
> Deepank
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to