Actually, by the time your action runs, the form bean is already created by
Struts.  It will be stored in request or session scope depending on what
you've specified in your Struts config file.   In this example, you're
pre-populating the form with data.  In a true application, your action would
most likely retrieve this data from the database -- not directly, but via
your business tier.

It's okay to have two actions and only one form.  The form is being re-used.
One action, such as save, may require performing validation on the form data
(i.e. configuring Struts to call the form's validate method), whereas
another action may not (e.g. a pre-populate action).   In this situation,
you could have two separate action classes, or just one action which uses an
action "mapping" parameter specified in the Struts configuration file to
determine which action is being executed.

-----Original Message-----
From: Mark Ayad [mailto:mark@;javamark.com]
Sent: Monday, November 04, 2002 10:38 AM
To: Struts Users Mailing List
Subject: Re: Populating a Form from the Model before view


John,

I have solved this using an EditForm Action  with it execute method as
follows:

EditForm editForm = (EditForm)form;

editForm.setTitle("title value");

editForm.setDetails("detail value");

return mapping.findForward("success");

Thus essentially building the formBean before the form is created (IS This
OK ?)

On Submit the form invokes the SaveAction which has the validation rules
here for the moment.

It works fine but now I've got 2 Actions for one Form.

My next question is how can the same be achived using dynamicForms ?

I would like to see some examples where data has to be edited using forms,
since most examples I've seen so far start with a blank form first.


----- Original Message -----
From: "Hohlen, John" <[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Monday, November 04, 2002 5:17 PM
Subject: RE: Populating a Form from the Model before view


> If I understood your question properly, you might want to look at my post
> from several months ago.
>
> http://www.mail-archive.com/struts-user@;jakarta.apache.org/msg43480.html
>
> -----Original Message-----
> From: Mark Ayad [mailto:mark@;javamark.com]
> Sent: Monday, November 04, 2002 3:04 AM
> To: [EMAIL PROTECTED]
> Subject: Populating a Form from the Model before view
>
>
> Hello,
>
> Could someone point out the process in Struts in which a Form is poulated
> form the model before being viewed.
>
> Most of the examples for Struts assume the Form is origianlly populated
from
> the view. I looking for the **reverse solution**. The sort of workflow for
> editing data ?
>
> Best Regards
>
> Mark
>
> --
> To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@;jakarta.apache.org>
> For additional commands, e-mail:
<mailto:struts-user-help@;jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail:
<mailto:struts-user-help@;jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@;jakarta.apache.org>

Reply via email to