RE: HOWTO pre-populate forms with data, then update ?

2003-01-23 Thread Karr, David
For other's benefit, that only applies for the ActionForm class
associated with the Action in the action-mapping.  If your "prepare
action" is associated with a different form bean, then that won't be
what you want.

However, you can have your "prepare action" and "process action"
action-mappings use the same form bean (make sure they are set in the
same scopes).  This would let you avoid writing the code to create the
form bean and put it into scope.  If your "prepare action" is also a
"process action" for another step, then this gets more complicated.

-Original Message-
From: David Graham [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 23, 2003 1:21 PM
To: [EMAIL PROTECTED]
Subject: Re: HOWTO pre-populate forms with data, then update ?

Struts hands you a form bean in your execute method.  You cast that
variable 
to your specific form type and use the setters to move data into it.
When 
you return an ActionForward object out of execute() struts will forward
to 
your input form with your populated bean.

You don't have to create the form bean yourself or put it into the
request, 
Struts does that for you as long as you tell it to in struts-config.xml.

David






>From: "Iain Sanderson" <[EMAIL PROTECTED]>
>Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>Subject: Re: HOWTO pre-populate forms with data, then update ?
>Date: Thu, 23 Jan 2003 15:43:22 -0500
>
>David,
>
>Thanks for your reply. How do you put the info into the form bean?
>
>I use a action called "RegistrationUpdateOpenAction"  to get the data
from
>the database and  forward to the view jsp (registrationUpdate.jsp), but
I
>don't know how to put that data into the form bean for this  ( the
>underlying form bean would be RegistrationUpdateForm). I'm confused as
the
>form bean is created/recycled by Struts on opening the view. How do I
get
>premptive access to it? Can I just create it and add it to the request
>scope? Won't struts create another one?
>
>Iain.
>
>
>Please respond to "Struts Users Mailing List"
><[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>cc:
>
>Subject:Re: HOWTO pre-populate forms with data, then update ?
>
>Traditionally you do this:
>1.  GetMyFormAction determines if it's add or edit from a query string
>attribute.
>2.  For edit go get the info from db using the record's id you passed
in
>the
>query string.
>3.  Put that info into your form bean.
>4.  Forward to your form
>
>The form's input elements will be prepopulated with data for the edit
>screen.
>
>David
>
>
>
>
>
>
> >From: "Iain Sanderson" <[EMAIL PROTECTED]>
> >Reply-To: "Struts Users Mailing List"
<[EMAIL PROTECTED]>
> >To: [EMAIL PROTECTED]
> >Subject: HOWTO pre-populate forms with data, then update ?
> >Date: Thu, 23 Jan 2003 15:20:40 -0500
> >
> >Newbie question:
> >
> >I've managed to use Struts forms as a means of  initial data entry (
> >registration forms etc) but have got  stuck on how to use a form to
>update
> >data that already exists in a database. For example, a form where a
user
> >can update their user details (address, email etc) and then submit
the
> >updates. How is this best done in struts ?
> >
> >I'm sure there's a good way of doing this, but my Kludge so far has
been
> >to  create a bean in the session scope containing the data I want to
> >populate the form with ( eg a user's current address), and then use
>struts
> >  html:text  tags to view  the bean data using their "name" and
>"property"
> >attributes.   Once the user has submitted their updates, the
ActionForm
> >accesses the form bean to obtain the updates, and applies the updates
to
> >the database.   I then of course have to update the  original bean's
data
> >with the new values ( eg their amended address) and send it back into
the
> >session scope.  It's a bit of a mess, but it works.
> >
> >I know there's a better way. Please help. Thanks.
> >
> >Iain Sanderson
> >
>
>
>_
>Add photos to your e-mail with MSN 8. Get 2 months FREE*.
>http://join.msn.com/?page=features/featuredemail
>
>
>--
>To unsubscribe, e-mail:   
><mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail: 
><mailto:[EMAIL PROTECTED]>
>
>
>
>


_
Add photos to your messages with MSN 8. Get 2 months FREE*.  
http://join.msn.com/?page=features/featuredemail


--
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]>




RE: HOWTO pre-populate forms with data, then update ?

2003-01-23 Thread Karr, David
No, your ActionForm.reset() method shouldn't be doing anything like
this.  That method is only intended to "clear" field values in
preparation for setting from the browser input form, and should not be
connected to any business logic in any way.

A "prepare action" and a "process action" are just Struts Action
classes.  You define action-mapping entries and forwards which navigate
between them.

-Original Message-
From: Hajratwala, Nayan (N.) [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 23, 2003 12:57 PM
To: 'Struts Users Mailing List'
Subject: RE: HOWTO pre-populate forms with data, then update ?

I have done this by setting up the initial values in the "reset()"
method.

Is that not the correct way to do it?  If not, how do you switch between
"prepare actions" and "process actions"?

---
- Nayan Hajratwala
- Chikli Consulting LLC
- http://www.chikli.com


-Original Message-
From: Karr, David [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 23, 2003 3:48 PM
To: Struts Users Mailing List
Subject: RE: HOWTO pre-populate forms with data, then update ?


In general, Struts applications will use "prepare actions" to prepare
the data for a form, and "process actions" to process the submitted data
for a form.  In your "prepare action" code, you'll interface with your
business logic to obtain the required data, then populate fields of a
bean, probably in request scope, not session scope, then you'll forward
to your page view, which will use the request scope bean to populate the
form.  Your "process action" will then take the fields from the form
(populated from the HTML fields) and send the changed values to your
business logic.

Usually, you can avoid putting most of this bean data into the session
scope.

-Original Message-
From: Iain Sanderson [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 23, 2003 12:21 PM
To: [EMAIL PROTECTED]
Subject: HOWTO pre-populate forms with data, then update ?

Newbie question:

I've managed to use Struts forms as a means of  initial data entry ( 
registration forms etc) but have got  stuck on how to use a form to
update 
data that already exists in a database. For example, a form where a user

can update their user details (address, email etc) and then submit the 
updates. How is this best done in struts ?

I'm sure there's a good way of doing this, but my Kludge so far has been

to  create a bean in the session scope containing the data I want to 
populate the form with ( eg a user's current address), and then use
struts 
 html:text  tags to view  the bean data using their "name" and
"property" 
attributes.   Once the user has submitted their updates, the ActionForm 
accesses the form bean to obtain the updates, and applies the updates to

the database.   I then of course have to update the  original bean's
data 
with the new values ( eg their amended address) and send it back into
the 
session scope.  It's a bit of a mess, but it works. 

I know there's a better way. Please help. Thanks.

Iain Sanderson
 

--
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]>




Re: HOWTO pre-populate forms with data, then update ?

2003-01-23 Thread David Graham
Struts hands you a form bean in your execute method.  You cast that variable 
to your specific form type and use the setters to move data into it.  When 
you return an ActionForward object out of execute() struts will forward to 
your input form with your populated bean.

You don't have to create the form bean yourself or put it into the request, 
Struts does that for you as long as you tell it to in struts-config.xml.

David






From: "Iain Sanderson" <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Subject: Re: HOWTO pre-populate forms with data, then update ?
Date: Thu, 23 Jan 2003 15:43:22 -0500

David,

Thanks for your reply. How do you put the info into the form bean?

I use a action called "RegistrationUpdateOpenAction"  to get the data from
the database and  forward to the view jsp (registrationUpdate.jsp), but I
don't know how to put that data into the form bean for this  ( the
underlying form bean would be RegistrationUpdateForm). I'm confused as the
form bean is created/recycled by Struts on opening the view. How do I get
premptive access to it? Can I just create it and add it to the request
scope? Won't struts create another one?

Iain.


Please respond to "Struts Users Mailing List"
<[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
cc:

Subject:Re: HOWTO pre-populate forms with data, then update ?

Traditionally you do this:
1.  GetMyFormAction determines if it's add or edit from a query string
attribute.
2.  For edit go get the info from db using the record's id you passed in
the
query string.
3.  Put that info into your form bean.
4.  Forward to your form

The form's input elements will be prepopulated with data for the edit
screen.

David






>From: "Iain Sanderson" <[EMAIL PROTECTED]>
>Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: HOWTO pre-populate forms with data, then update ?
>Date: Thu, 23 Jan 2003 15:20:40 -0500
>
>Newbie question:
>
>I've managed to use Struts forms as a means of  initial data entry (
>registration forms etc) but have got  stuck on how to use a form to
update
>data that already exists in a database. For example, a form where a user
>can update their user details (address, email etc) and then submit the
>updates. How is this best done in struts ?
>
>I'm sure there's a good way of doing this, but my Kludge so far has been
>to  create a bean in the session scope containing the data I want to
>populate the form with ( eg a user's current address), and then use
struts
>  html:text  tags to view  the bean data using their "name" and
"property"
>attributes.   Once the user has submitted their updates, the ActionForm
>accesses the form bean to obtain the updates, and applies the updates to
>the database.   I then of course have to update the  original bean's data
>with the new values ( eg their amended address) and send it back into the
>session scope.  It's a bit of a mess, but it works.
>
>I know there's a better way. Please help. Thanks.
>
>Iain Sanderson
>


_
Add photos to your e-mail with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail


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






_
Add photos to your messages with MSN 8. Get 2 months FREE*.  
http://join.msn.com/?page=features/featuredemail


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



RE: HOWTO pre-populate forms with data, then update ?

2003-01-23 Thread Iain Sanderson
Alberto,

Perfect. And thanks, I'll give it a try. I'm sure this is what I needed to 
do.

Iain.


Please respond to "Struts Users Mailing List" 
<[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
cc: 

Subject:    RE: HOWTO pre-populate forms with data, then update ?

You can create an instance of the form you need (if is not the one you are
already getting in the execute method).
Once you have the form, you can then populate it. Then add it to the 
request
using the name you defined for this form within your struts-config file.

You'll have something like:
---
RegistrationUpdateForm myform = new RegistrationUpdateForm();
//populate myForm
...
//Add it to the request
request.setAttribute("formNameFromStrutsConfigFile", myform);
return mappings.findForward("success");


Regards,
Alberto Corona
VP Of Consulting Services
ObjectWave Corp.


-Original Message-
From: Iain Sanderson [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 23, 2003 2:43 PM
To: Struts Users Mailing List
Subject: Re: HOWTO pre-populate forms with data, then update ?


David,

Thanks for your reply. How do you put the info into the form bean?

I use a action called "RegistrationUpdateOpenAction"  to get the data from
the database and  forward to the view jsp (registrationUpdate.jsp), but I
don't know how to put that data into the form bean for this  ( the
underlying form bean would be RegistrationUpdateForm). I'm confused as the
form bean is created/recycled by Struts on opening the view. How do I get
premptive access to it? Can I just create it and add it to the request
scope? Won't struts create another one?

Iain.


Please respond to "Struts Users Mailing List"
<[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
cc:

Subject:Re: HOWTO pre-populate forms with data, then update ?

Traditionally you do this:
1.  GetMyFormAction determines if it's add or edit from a query string
attribute.
2.  For edit go get the info from db using the record's id you passed in
the
query string.
3.  Put that info into your form bean.
4.  Forward to your form

The form's input elements will be prepopulated with data for the edit
screen.

David






>From: "Iain Sanderson" <[EMAIL PROTECTED]>
>Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: HOWTO pre-populate forms with data, then update ?
>Date: Thu, 23 Jan 2003 15:20:40 -0500
>
>Newbie question:
>
>I've managed to use Struts forms as a means of  initial data entry (
>registration forms etc) but have got  stuck on how to use a form to
update
>data that already exists in a database. For example, a form where a user
>can update their user details (address, email etc) and then submit the
>updates. How is this best done in struts ?
>
>I'm sure there's a good way of doing this, but my Kludge so far has been
>to  create a bean in the session scope containing the data I want to
>populate the form with ( eg a user's current address), and then use
struts
>  html:text  tags to view  the bean data using their "name" and
"property"
>attributes.   Once the user has submitted their updates, the ActionForm
>accesses the form bean to obtain the updates, and applies the updates to
>the database.   I then of course have to update the  original bean's data
>with the new values ( eg their amended address) and send it back into the
>session scope.  It's a bit of a mess, but it works.
>
>I know there's a better way. Please help. Thanks.
>
>Iain Sanderson
>


_
Add photos to your e-mail with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail


--
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]>







RE: HOWTO pre-populate forms with data, then update ?

2003-01-23 Thread Iain Sanderson
Not at all, 'cos I was thinking of doing it this way, but the other 
replies show what we should be doing, I think. Thanks anyway.

Iain.


Please respond to "Struts Users Mailing List" 
<[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
cc: 

Subject:    RE: HOWTO pre-populate forms with data, then update ?

Depends on how hard you're going to flame me =)

Actually yes, but I'm guessing from your tone that I'm being a bad boy.

---
- Nayan Hajratwala
- Chikli Consulting LLC
- http://www.chikli.com


-Original Message-
From: Iain Sanderson [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 23, 2003 3:59 PM
To: Struts Users Mailing List
Subject: RE: HOWTO pre-populate forms with data, then update ?


Nayan,

Are you accessing the business logic ( or database) in the reset method to 

determine the initial values?

Iain


Please respond to "Struts Users Mailing List" 
<[EMAIL PROTECTED]>
To:     "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
cc: 

Subject:RE: HOWTO pre-populate forms with data, then update ?

I have done this by setting up the initial values in the "reset()" method.

Is that not the correct way to do it?  If not, how do you switch between 
"prepare actions" and "process actions"?

---
- Nayan Hajratwala
- Chikli Consulting LLC
- http://www.chikli.com


-Original Message-----
From: Karr, David [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 23, 2003 3:48 PM
To: Struts Users Mailing List
Subject: RE: HOWTO pre-populate forms with data, then update ?


In general, Struts applications will use "prepare actions" to prepare
the data for a form, and "process actions" to process the submitted data
for a form.  In your "prepare action" code, you'll interface with your
business logic to obtain the required data, then populate fields of a
bean, probably in request scope, not session scope, then you'll forward
to your page view, which will use the request scope bean to populate the
form.  Your "process action" will then take the fields from the form
(populated from the HTML fields) and send the changed values to your
business logic.

Usually, you can avoid putting most of this bean data into the session
scope.

-Original Message-
From: Iain Sanderson [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 23, 2003 12:21 PM
To: [EMAIL PROTECTED]
Subject: HOWTO pre-populate forms with data, then update ?

Newbie question:

I've managed to use Struts forms as a means of  initial data entry ( 
registration forms etc) but have got  stuck on how to use a form to
update 
data that already exists in a database. For example, a form where a user

can update their user details (address, email etc) and then submit the 
updates. How is this best done in struts ?

I'm sure there's a good way of doing this, but my Kludge so far has been

to  create a bean in the session scope containing the data I want to 
populate the form with ( eg a user's current address), and then use
struts 
 html:text  tags to view  the bean data using their "name" and
"property" 
attributes.   Once the user has submitted their updates, the ActionForm 
accesses the form bean to obtain the updates, and applies the updates to

the database.   I then of course have to update the  original bean's
data 
with the new values ( eg their amended address) and send it back into
the 
session scope.  It's a bit of a mess, but it works. 

I know there's a better way. Please help. Thanks.

Iain Sanderson
 

--
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]>







RE: HOWTO pre-populate forms with data, then update ?

2003-01-23 Thread Hajratwala, Nayan (N.)
Depends on how hard you're going to flame me =)

Actually yes, but I'm guessing from your tone that I'm being a bad boy.

---
- Nayan Hajratwala
- Chikli Consulting LLC
- http://www.chikli.com


-Original Message-
From: Iain Sanderson [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 23, 2003 3:59 PM
To: Struts Users Mailing List
Subject: RE: HOWTO pre-populate forms with data, then update ?


Nayan,

Are you accessing the business logic ( or database) in the reset method to 
determine the initial values?

Iain


Please respond to "Struts Users Mailing List" 
<[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
cc: 

Subject:    RE: HOWTO pre-populate forms with data, then update ?

I have done this by setting up the initial values in the "reset()" method.

Is that not the correct way to do it?  If not, how do you switch between 
"prepare actions" and "process actions"?

---
- Nayan Hajratwala
- Chikli Consulting LLC
- http://www.chikli.com


-Original Message-
From: Karr, David [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 23, 2003 3:48 PM
To: Struts Users Mailing List
Subject: RE: HOWTO pre-populate forms with data, then update ?


In general, Struts applications will use "prepare actions" to prepare
the data for a form, and "process actions" to process the submitted data
for a form.  In your "prepare action" code, you'll interface with your
business logic to obtain the required data, then populate fields of a
bean, probably in request scope, not session scope, then you'll forward
to your page view, which will use the request scope bean to populate the
form.  Your "process action" will then take the fields from the form
(populated from the HTML fields) and send the changed values to your
business logic.

Usually, you can avoid putting most of this bean data into the session
scope.

-Original Message-
From: Iain Sanderson [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 23, 2003 12:21 PM
To: [EMAIL PROTECTED]
Subject: HOWTO pre-populate forms with data, then update ?

Newbie question:

I've managed to use Struts forms as a means of  initial data entry ( 
registration forms etc) but have got  stuck on how to use a form to
update 
data that already exists in a database. For example, a form where a user

can update their user details (address, email etc) and then submit the 
updates. How is this best done in struts ?

I'm sure there's a good way of doing this, but my Kludge so far has been

to  create a bean in the session scope containing the data I want to 
populate the form with ( eg a user's current address), and then use
struts 
 html:text  tags to view  the bean data using their "name" and
"property" 
attributes.   Once the user has submitted their updates, the ActionForm 
accesses the form bean to obtain the updates, and applies the updates to

the database.   I then of course have to update the  original bean's
data 
with the new values ( eg their amended address) and send it back into
the 
session scope.  It's a bit of a mess, but it works. 

I know there's a better way. Please help. Thanks.

Iain Sanderson
 

--
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]>




RE: HOWTO pre-populate forms with data, then update ?

2003-01-23 Thread Alberto Corona
You can create an instance of the form you need (if is not the one you are
already getting in the execute method).
Once you have the form, you can then populate it. Then add it to the request
using the name you defined for this form within your struts-config file.

You'll have something like:
---
RegistrationUpdateForm myform = new RegistrationUpdateForm();
//populate myForm
...
//Add it to the request
request.setAttribute("formNameFromStrutsConfigFile", myform);
return mappings.findForward("success");


Regards,
Alberto Corona
VP Of Consulting Services
ObjectWave Corp.


-Original Message-
From: Iain Sanderson [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 23, 2003 2:43 PM
To: Struts Users Mailing List
Subject: Re: HOWTO pre-populate forms with data, then update ?


David,

Thanks for your reply. How do you put the info into the form bean?

I use a action called "RegistrationUpdateOpenAction"  to get the data from
the database and  forward to the view jsp (registrationUpdate.jsp), but I
don't know how to put that data into the form bean for this  ( the
underlying form bean would be RegistrationUpdateForm). I'm confused as the
form bean is created/recycled by Struts on opening the view. How do I get
premptive access to it? Can I just create it and add it to the request
scope? Won't struts create another one?

Iain.


Please respond to "Struts Users Mailing List"
<[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
cc:

Subject:Re: HOWTO pre-populate forms with data, then update ?

Traditionally you do this:
1.  GetMyFormAction determines if it's add or edit from a query string
attribute.
2.  For edit go get the info from db using the record's id you passed in
the
query string.
3.  Put that info into your form bean.
4.  Forward to your form

The form's input elements will be prepopulated with data for the edit
screen.

David






>From: "Iain Sanderson" <[EMAIL PROTECTED]>
>Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: HOWTO pre-populate forms with data, then update ?
>Date: Thu, 23 Jan 2003 15:20:40 -0500
>
>Newbie question:
>
>I've managed to use Struts forms as a means of  initial data entry (
>registration forms etc) but have got  stuck on how to use a form to
update
>data that already exists in a database. For example, a form where a user
>can update their user details (address, email etc) and then submit the
>updates. How is this best done in struts ?
>
>I'm sure there's a good way of doing this, but my Kludge so far has been
>to  create a bean in the session scope containing the data I want to
>populate the form with ( eg a user's current address), and then use
struts
>  html:text  tags to view  the bean data using their "name" and
"property"
>attributes.   Once the user has submitted their updates, the ActionForm
>accesses the form bean to obtain the updates, and applies the updates to
>the database.   I then of course have to update the  original bean's data
>with the new values ( eg their amended address) and send it back into the
>session scope.  It's a bit of a mess, but it works.
>
>I know there's a better way. Please help. Thanks.
>
>Iain Sanderson
>


_
Add photos to your e-mail with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail


--
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]>




Re: HOWTO pre-populate forms with data, then update ?

2003-01-23 Thread Eric Rizzo
Iain Sanderson wrote:

David,

Thanks for your reply. How do you put the info into the form bean?

I use a action called "RegistrationUpdateOpenAction"  to get the data from 
the database and  forward to the view jsp (registrationUpdate.jsp), but I 
don't know how to put that data into the form bean for this  ( the 
underlying form bean would be RegistrationUpdateForm). I'm confused as the 
form bean is created/recycled by Struts on opening the view. How do I get 
premptive access to it? Can I just create it and add it to the request 
scope? Won't struts create another one?

The form bean instance is passed into your action's perform or execute 
method. Just populate it and return a forward to the JSP.

HTH,
	Eric
--
Eric Rizzo
Software Architect
Jibe, Inc.
http://www.jibeinc.com


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 



RE: HOWTO pre-populate forms with data, then update ?

2003-01-23 Thread Iain Sanderson
Nayan,

Are you accessing the business logic ( or database) in the reset method to 
determine the initial values?

Iain


Please respond to "Struts Users Mailing List" 
<[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
cc: 

Subject:    RE: HOWTO pre-populate forms with data, then update ?

I have done this by setting up the initial values in the "reset()" method.

Is that not the correct way to do it?  If not, how do you switch between 
"prepare actions" and "process actions"?

---
- Nayan Hajratwala
- Chikli Consulting LLC
- http://www.chikli.com


-Original Message-
From: Karr, David [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 23, 2003 3:48 PM
To: Struts Users Mailing List
Subject: RE: HOWTO pre-populate forms with data, then update ?


In general, Struts applications will use "prepare actions" to prepare
the data for a form, and "process actions" to process the submitted data
for a form.  In your "prepare action" code, you'll interface with your
business logic to obtain the required data, then populate fields of a
bean, probably in request scope, not session scope, then you'll forward
to your page view, which will use the request scope bean to populate the
form.  Your "process action" will then take the fields from the form
(populated from the HTML fields) and send the changed values to your
business logic.

Usually, you can avoid putting most of this bean data into the session
scope.

-Original Message-
From: Iain Sanderson [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 23, 2003 12:21 PM
To: [EMAIL PROTECTED]
Subject: HOWTO pre-populate forms with data, then update ?

Newbie question:

I've managed to use Struts forms as a means of  initial data entry ( 
registration forms etc) but have got  stuck on how to use a form to
update 
data that already exists in a database. For example, a form where a user

can update their user details (address, email etc) and then submit the 
updates. How is this best done in struts ?

I'm sure there's a good way of doing this, but my Kludge so far has been

to  create a bean in the session scope containing the data I want to 
populate the form with ( eg a user's current address), and then use
struts 
 html:text  tags to view  the bean data using their "name" and
"property" 
attributes.   Once the user has submitted their updates, the ActionForm 
accesses the form bean to obtain the updates, and applies the updates to

the database.   I then of course have to update the  original bean's
data 
with the new values ( eg their amended address) and send it back into
the 
session scope.  It's a bit of a mess, but it works. 

I know there's a better way. Please help. Thanks.

Iain Sanderson
 

--
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]>







RE: HOWTO pre-populate forms with data, then update ?

2003-01-23 Thread Hajratwala, Nayan (N.)
I have done this by setting up the initial values in the "reset()" method.

Is that not the correct way to do it?  If not, how do you switch between "prepare 
actions" and "process actions"?

---
- Nayan Hajratwala
- Chikli Consulting LLC
- http://www.chikli.com


-Original Message-
From: Karr, David [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 23, 2003 3:48 PM
To: Struts Users Mailing List
Subject: RE: HOWTO pre-populate forms with data, then update ?


In general, Struts applications will use "prepare actions" to prepare
the data for a form, and "process actions" to process the submitted data
for a form.  In your "prepare action" code, you'll interface with your
business logic to obtain the required data, then populate fields of a
bean, probably in request scope, not session scope, then you'll forward
to your page view, which will use the request scope bean to populate the
form.  Your "process action" will then take the fields from the form
(populated from the HTML fields) and send the changed values to your
business logic.

Usually, you can avoid putting most of this bean data into the session
scope.

-Original Message-
From: Iain Sanderson [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 23, 2003 12:21 PM
To: [EMAIL PROTECTED]
Subject: HOWTO pre-populate forms with data, then update ?

Newbie question:

I've managed to use Struts forms as a means of  initial data entry ( 
registration forms etc) but have got  stuck on how to use a form to
update 
data that already exists in a database. For example, a form where a user

can update their user details (address, email etc) and then submit the 
updates. How is this best done in struts ?

I'm sure there's a good way of doing this, but my Kludge so far has been

to  create a bean in the session scope containing the data I want to 
populate the form with ( eg a user's current address), and then use
struts 
 html:text  tags to view  the bean data using their "name" and
"property" 
attributes.   Once the user has submitted their updates, the ActionForm 
accesses the form bean to obtain the updates, and applies the updates to

the database.   I then of course have to update the  original bean's
data 
with the new values ( eg their amended address) and send it back into
the 
session scope.  It's a bit of a mess, but it works. 

I know there's a better way. Please help. Thanks.

Iain Sanderson
 

--
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]>




RE: HOWTO pre-populate forms with data, then update ?

2003-01-23 Thread Iain Sanderson
Yes,

I'm really doing precisely this - but I don't know how to transfer the 
data from the business logic to the form bean underlying the the page 
view. My kludge is to get around this deficiency.  How is it done?

Iain


Please respond to "Struts Users Mailing List" 
<[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
cc: 

Subject:    RE: HOWTO pre-populate forms with data, then update ?

In general, Struts applications will use "prepare actions" to prepare
the data for a form, and "process actions" to process the submitted data
for a form.  In your "prepare action" code, you'll interface with your
business logic to obtain the required data, then populate fields of a
bean, probably in request scope, not session scope, then you'll forward
to your page view, which will use the request scope bean to populate the
form.  Your "process action" will then take the fields from the form
(populated from the HTML fields) and send the changed values to your
business logic.

Usually, you can avoid putting most of this bean data into the session
scope.

-Original Message-
From: Iain Sanderson [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 23, 2003 12:21 PM
To: [EMAIL PROTECTED]
Subject: HOWTO pre-populate forms with data, then update ?

Newbie question:

I've managed to use Struts forms as a means of  initial data entry ( 
registration forms etc) but have got  stuck on how to use a form to
update 
data that already exists in a database. For example, a form where a user

can update their user details (address, email etc) and then submit the 
updates. How is this best done in struts ?

I'm sure there's a good way of doing this, but my Kludge so far has been

to  create a bean in the session scope containing the data I want to 
populate the form with ( eg a user's current address), and then use
struts 
 html:text  tags to view  the bean data using their "name" and
"property" 
attributes.   Once the user has submitted their updates, the ActionForm 
accesses the form bean to obtain the updates, and applies the updates to

the database.   I then of course have to update the  original bean's
data 
with the new values ( eg their amended address) and send it back into
the 
session scope.  It's a bit of a mess, but it works. 

I know there's a better way. Please help. Thanks.

Iain Sanderson
 

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







RE: HOWTO pre-populate forms with data, then update ?

2003-01-23 Thread Karr, David
In general, Struts applications will use "prepare actions" to prepare
the data for a form, and "process actions" to process the submitted data
for a form.  In your "prepare action" code, you'll interface with your
business logic to obtain the required data, then populate fields of a
bean, probably in request scope, not session scope, then you'll forward
to your page view, which will use the request scope bean to populate the
form.  Your "process action" will then take the fields from the form
(populated from the HTML fields) and send the changed values to your
business logic.

Usually, you can avoid putting most of this bean data into the session
scope.

-Original Message-
From: Iain Sanderson [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 23, 2003 12:21 PM
To: [EMAIL PROTECTED]
Subject: HOWTO pre-populate forms with data, then update ?

Newbie question:

I've managed to use Struts forms as a means of  initial data entry ( 
registration forms etc) but have got  stuck on how to use a form to
update 
data that already exists in a database. For example, a form where a user

can update their user details (address, email etc) and then submit the 
updates. How is this best done in struts ?

I'm sure there's a good way of doing this, but my Kludge so far has been

to  create a bean in the session scope containing the data I want to 
populate the form with ( eg a user's current address), and then use
struts 
 html:text  tags to view  the bean data using their "name" and
"property" 
attributes.   Once the user has submitted their updates, the ActionForm 
accesses the form bean to obtain the updates, and applies the updates to

the database.   I then of course have to update the  original bean's
data 
with the new values ( eg their amended address) and send it back into
the 
session scope.  It's a bit of a mess, but it works. 

I know there's a better way. Please help. Thanks.

Iain Sanderson
 

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: HOWTO pre-populate forms with data, then update ?

2003-01-23 Thread Iain Sanderson
David,

Thanks for your reply. How do you put the info into the form bean?

I use a action called "RegistrationUpdateOpenAction"  to get the data from 
the database and  forward to the view jsp (registrationUpdate.jsp), but I 
don't know how to put that data into the form bean for this  ( the 
underlying form bean would be RegistrationUpdateForm). I'm confused as the 
form bean is created/recycled by Struts on opening the view. How do I get 
premptive access to it? Can I just create it and add it to the request 
scope? Won't struts create another one?

Iain.


Please respond to "Struts Users Mailing List" 
<[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
cc: 

Subject:    Re: HOWTO pre-populate forms with data, then update ?

Traditionally you do this:
1.  GetMyFormAction determines if it's add or edit from a query string 
attribute.
2.  For edit go get the info from db using the record's id you passed in 
the 
query string.
3.  Put that info into your form bean.
4.  Forward to your form

The form's input elements will be prepopulated with data for the edit 
screen.

David






>From: "Iain Sanderson" <[EMAIL PROTECTED]>
>Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: HOWTO pre-populate forms with data, then update ?
>Date: Thu, 23 Jan 2003 15:20:40 -0500
>
>Newbie question:
>
>I've managed to use Struts forms as a means of  initial data entry (
>registration forms etc) but have got  stuck on how to use a form to 
update
>data that already exists in a database. For example, a form where a user
>can update their user details (address, email etc) and then submit the
>updates. How is this best done in struts ?
>
>I'm sure there's a good way of doing this, but my Kludge so far has been
>to  create a bean in the session scope containing the data I want to
>populate the form with ( eg a user's current address), and then use 
struts
>  html:text  tags to view  the bean data using their "name" and 
"property"
>attributes.   Once the user has submitted their updates, the ActionForm
>accesses the form bean to obtain the updates, and applies the updates to
>the database.   I then of course have to update the  original bean's data
>with the new values ( eg their amended address) and send it back into the
>session scope.  It's a bit of a mess, but it works.
>
>I know there's a better way. Please help. Thanks.
>
>Iain Sanderson
>


_
Add photos to your e-mail with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?page=features/featuredemail


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







Re: HOWTO pre-populate forms with data, then update ?

2003-01-23 Thread David Graham
Traditionally you do this:
1.  GetMyFormAction determines if it's add or edit from a query string 
attribute.
2.  For edit go get the info from db using the record's id you passed in the 
query string.
3.  Put that info into your form bean.
4.  Forward to your form

The form's input elements will be prepopulated with data for the edit 
screen.

David






From: "Iain Sanderson" <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: HOWTO pre-populate forms with data, then update ?
Date: Thu, 23 Jan 2003 15:20:40 -0500

Newbie question:

I've managed to use Struts forms as a means of  initial data entry (
registration forms etc) but have got  stuck on how to use a form to update
data that already exists in a database. For example, a form where a user
can update their user details (address, email etc) and then submit the
updates. How is this best done in struts ?

I'm sure there's a good way of doing this, but my Kludge so far has been
to  create a bean in the session scope containing the data I want to
populate the form with ( eg a user's current address), and then use struts
 html:text  tags to view  the bean data using their "name" and "property"
attributes.   Once the user has submitted their updates, the ActionForm
accesses the form bean to obtain the updates, and applies the updates to
the database.   I then of course have to update the  original bean's data
with the new values ( eg their amended address) and send it back into the
session scope.  It's a bit of a mess, but it works.

I know there's a better way. Please help. Thanks.

Iain Sanderson




_
Add photos to your e-mail with MSN 8. Get 2 months FREE*.  
http://join.msn.com/?page=features/featuredemail


--
To unsubscribe, e-mail:   
For additional commands, e-mail: