RE: Populating a Form from the Model before view

2002-11-07 Thread Donald Dwoske

this example works by going through the action, so the
url you need to use must go through the action...

http://hostname/myAction.do  

do not go through:

http://hostname/myPage.jsp   # your Action will not execute


What also might catch you is that by going through the
action, it forces the the validate() method of the
Form bean to be called, so if your validate fails,
your action will never get a chance to run, which in this
case is bad because you haven't populated your view yet!

I've got some smarts in my Form by using a hidden field
so that the validate method knows what the user is doing
so as not to fail if the model data has not been populated yet.

So I might edit data with http://hostname/editUser.do?action='load'id='jsmith'

and when clicking the save button on my page after editing, i
change the hidden text field named 'action' to be 'save'

In this way validate() knows to do something different in the
action='load' case as opposed to an action='save' case.

In the 'load' case, my required field may be only 'id' but in
the 'edit' case, i may have lots of required fields, 'firstName', 'ssn', etc...

-don

-Original Message-
From: Marcus Biel [mailto:Marcus.Biel;bmw.de]
Sent: Thursday, November 07, 2002 6:18 AM
To: [EMAIL PROTECTED]
Subject: Re: Populating a Form from the Model before view


Your Action ... (){
perform(...ActionForm form..) {
...
..
.
YourActionForm yourActionForm = (YourActionForm)form;
...
..
.
yourActionForm.setYourProperty(yourPropertyValue);
}
}

[EMAIL PROTECTED] schrieb:
 
 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




Populating a Form from the Model before view

2002-11-04 Thread Mark Ayad
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



RE: Populating a Form from the Model before view

2002-11-04 Thread Hohlen, John
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




Re: Populating a Form from the Model before view

2002-11-04 Thread Mark Ayad
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




RE: Populating a Form from the Model before view

2002-11-04 Thread Hohlen, John
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




Re: Populating a Form from the Model before view

2002-11-04 Thread Mark Ayad
... and for dynamic forms, what then ?

Mark

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


 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




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




Re: Populating a Form from the Model before view

2002-11-04 Thread Craig R. McClanahan


On Mon, 4 Nov 2002, Mark Ayad wrote:

 Date: Mon, 4 Nov 2002 10:03:48 +0100
 From: Mark Ayad [EMAIL PROTECTED]
 Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
 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 ?


The Struts example app includes a use case like this, because it lets you
either create new database info or edit existing database info.  In the
latter case, the pre-population is done with a separate Action than the
database update.

 Best Regards

 Mark


Craig



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