RE: Form Bean Help?

2003-07-29 Thread Matt E
Wendy,

> If you need to pre-populate the form, read the DTO
> from the database and use
> BeanUtils.copyProperties(...) to copy the DTO values
> into the Form bean
> before forwarding to the view.
> 
> Take a look at the struts-example webapp, it works
> the way you're
> describing.

Outstanding!  This sounds like exactly what I want. 
I'll check it out, and post back if I have any
questions.

Cheers!

__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

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



RE: Form Bean Help?

2003-07-29 Thread Mainguy, Mike
Whoops, I completely missed that, Red Herring alert!

-Original Message-
From: Wendy Smoak [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 29, 2003 12:56 PM
To: 'Struts Users Mailing List'
Subject: RE: Form Bean Help?

Matt wrote:
> I had been using the value property of the struts-html
> tags to fill in the data, but I've noticed that when
> the user hits submit, if there is a validation error,
> they are pushed back to the page, and the data they
> had enetered is replaced with what was in the DTO
> (which is now old data).

Don't use the 'value' attribute, just let Struts render the HTML form
elements based on what's stored in the Form bean.  That will fix the
redisplay on validation problem.

If you need to pre-populate the form, read the DTO from the database and use
BeanUtils.copyProperties(...) to copy the DTO values into the Form bean
before forwarding to the view.

Take a look at the struts-example webapp, it works the way you're
describing.

-- 
Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University, PA, IRM 

This message and its contents (to include attachments) are the property of Kmart 
Corporation (Kmart) and may contain confidential and proprietary information. You are 
hereby notified that any disclosure, copying, or distribution of this message, or the 
taking of any action based on information contained herein is strictly prohibited. 
Unauthorized use of information contained herein may subject you to civil and criminal 
prosecution and penalties. If you are not the intended recipient, you should delete 
this message immediately.



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



RE: Form Bean Help?

2003-07-29 Thread Mainguy, Mike
Ok, that's fine, but why are you loading data from the database when you are
performing an update operation?  I think you'd want to first determine what
sort of operation you are doing before assuming that you want to overlay
what is currently in the Form with what is stored in your database.  

I guess what I'm saying is that, if you want to use the data that was
posted, you shouldn't need to do anything...  When I do an update and it
fails, I just leave my ActionForm alone and the data that I posted is what
stays there.  I'm saying use an operation in your action to determine what
your data operation is BEFORE assuming you want to modify your actionform...
after all, you may want to revert to the old copy... I use my actionForm as
a holding area to inspect and validate the data before moving it into my
model tier.  If my model update fails, then I leave the form alone and
redisplay the old copy with the current form.

Am I misunderstanding what you are trying to do  perhaps?

-Original Message-
From: Matt E [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 29, 2003 12:46 PM
To: Struts Users Mailing List
Subject: RE: Form Bean Help?

Mike,

The bean is stored in the Session scope (the bean
needs to be stored in the session scope, so that some
other data for it which is valid for the life of the
session stays around).

Even if it was a request scoped bean, I'd still like a
way to fill out the action form before hand, because
then things like Radio buttons could be "preselected"
based on what I loaded from the database.

Cheers.
--- "Mainguy, Mike" <[EMAIL PROTECTED]> wrote:
> My angle on this is to only load the data from the
> database when the user is
> submitted a request to "read" data.  If they are
> submitting an "update"
> action, I don't load the data from the database.
>  
> -Original Message-
> From: Matt E [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, July 29, 2003 12:37 PM
> To: [EMAIL PROTECTED]
> Subject: Form Bean Help?
> 
> Hello All,
> 
> I'm running into a little problem, maybe someone can
> help me fix it.
> 
> My application is driven by filling out web forms. 
> At
> one point, A user can click the "Save Form" button,
> which writes the form information to a Database. 
> When
> the user visits the page again, the action builds a
> DTO that contains all the information they had
> filled
> out and puts it in the session scope, then forwards
> to
> the JSP page that has the form on it.
> 
> I had been using the value property of the
> struts-html
> tags to fill in the data, but I've noticed that when
> the user hits submit, if there is a validation
> error,
> they are pushed back to the page, and the data they
> had enetered is replaced with what was in the DTO
> (which is now old data).  I've also run into the
> problem of filling in things like radio buttons,
> based
> on what was in the DTO.
> 
> It seems to me that what I want to do is not pass
> along the DTO with the action, but fill out parts of
> the Form Bean before forwarding to the page that
> displays it, at which point I could remove the value
> properties of the html tags, and have everything
> work.
> 
> My question is, how can I do this from the action? 
> Or
> do I want to attack this problem in another way?
> 
> Thanks!
> 
> __
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site
> design software
> http://sitebuilder.yahoo.com
> 
>
-
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> 
> This message and its contents (to include
> attachments) are the property of Kmart Corporation
> (Kmart) and may contain confidential and proprietary
> information. You are hereby notified that any
> disclosure, copying, or distribution of this
> message, or the taking of any action based on
> information contained herein is strictly prohibited.
> Unauthorized use of information contained herein may
> subject you to civil and criminal prosecution and
> penalties. If you are not the intended recipient,
> you should delete this message immediately.
> 
> 
> 
>
-
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 


__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For addition

RE: Form Bean Help?

2003-07-29 Thread Wendy Smoak
Matt wrote:
> I had been using the value property of the struts-html
> tags to fill in the data, but I've noticed that when
> the user hits submit, if there is a validation error,
> they are pushed back to the page, and the data they
> had enetered is replaced with what was in the DTO
> (which is now old data).

Don't use the 'value' attribute, just let Struts render the HTML form
elements based on what's stored in the Form bean.  That will fix the
redisplay on validation problem.

If you need to pre-populate the form, read the DTO from the database and use
BeanUtils.copyProperties(...) to copy the DTO values into the Form bean
before forwarding to the view.

Take a look at the struts-example webapp, it works the way you're
describing.

-- 
Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University, PA, IRM 


RE: Form Bean Help?

2003-07-29 Thread Matt E
Mike,

The bean is stored in the Session scope (the bean
needs to be stored in the session scope, so that some
other data for it which is valid for the life of the
session stays around).

Even if it was a request scoped bean, I'd still like a
way to fill out the action form before hand, because
then things like Radio buttons could be "preselected"
based on what I loaded from the database.

Cheers.
--- "Mainguy, Mike" <[EMAIL PROTECTED]> wrote:
> My angle on this is to only load the data from the
> database when the user is
> submitted a request to "read" data.  If they are
> submitting an "update"
> action, I don't load the data from the database.
>  
> -Original Message-
> From: Matt E [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, July 29, 2003 12:37 PM
> To: [EMAIL PROTECTED]
> Subject: Form Bean Help?
> 
> Hello All,
> 
> I'm running into a little problem, maybe someone can
> help me fix it.
> 
> My application is driven by filling out web forms. 
> At
> one point, A user can click the "Save Form" button,
> which writes the form information to a Database. 
> When
> the user visits the page again, the action builds a
> DTO that contains all the information they had
> filled
> out and puts it in the session scope, then forwards
> to
> the JSP page that has the form on it.
> 
> I had been using the value property of the
> struts-html
> tags to fill in the data, but I've noticed that when
> the user hits submit, if there is a validation
> error,
> they are pushed back to the page, and the data they
> had enetered is replaced with what was in the DTO
> (which is now old data).  I've also run into the
> problem of filling in things like radio buttons,
> based
> on what was in the DTO.
> 
> It seems to me that what I want to do is not pass
> along the DTO with the action, but fill out parts of
> the Form Bean before forwarding to the page that
> displays it, at which point I could remove the value
> properties of the html tags, and have everything
> work.
> 
> My question is, how can I do this from the action? 
> Or
> do I want to attack this problem in another way?
> 
> Thanks!
> 
> __
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site
> design software
> http://sitebuilder.yahoo.com
> 
>
-
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> 
> This message and its contents (to include
> attachments) are the property of Kmart Corporation
> (Kmart) and may contain confidential and proprietary
> information. You are hereby notified that any
> disclosure, copying, or distribution of this
> message, or the taking of any action based on
> information contained herein is strictly prohibited.
> Unauthorized use of information contained herein may
> subject you to civil and criminal prosecution and
> penalties. If you are not the intended recipient,
> you should delete this message immediately.
> 
> 
> 
>
-
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 


__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

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



RE: Form Bean Help?

2003-07-29 Thread Mainguy, Mike
My angle on this is to only load the data from the database when the user is
submitted a request to "read" data.  If they are submitting an "update"
action, I don't load the data from the database.
 
-Original Message-
From: Matt E [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 29, 2003 12:37 PM
To: [EMAIL PROTECTED]
Subject: Form Bean Help?

Hello All,

I'm running into a little problem, maybe someone can
help me fix it.

My application is driven by filling out web forms.  At
one point, A user can click the "Save Form" button,
which writes the form information to a Database.  When
the user visits the page again, the action builds a
DTO that contains all the information they had filled
out and puts it in the session scope, then forwards to
the JSP page that has the form on it.

I had been using the value property of the struts-html
tags to fill in the data, but I've noticed that when
the user hits submit, if there is a validation error,
they are pushed back to the page, and the data they
had enetered is replaced with what was in the DTO
(which is now old data).  I've also run into the
problem of filling in things like radio buttons, based
on what was in the DTO.

It seems to me that what I want to do is not pass
along the DTO with the action, but fill out parts of
the Form Bean before forwarding to the page that
displays it, at which point I could remove the value
properties of the html tags, and have everything work.

My question is, how can I do this from the action?  Or
do I want to attack this problem in another way?

Thanks!

__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

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


This message and its contents (to include attachments) are the property of Kmart 
Corporation (Kmart) and may contain confidential and proprietary information. You are 
hereby notified that any disclosure, copying, or distribution of this message, or the 
taking of any action based on information contained herein is strictly prohibited. 
Unauthorized use of information contained herein may subject you to civil and criminal 
prosecution and penalties. If you are not the intended recipient, you should delete 
this message immediately.



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



Form Bean Help?

2003-07-29 Thread Matt E
Hello All,

I'm running into a little problem, maybe someone can
help me fix it.

My application is driven by filling out web forms.  At
one point, A user can click the "Save Form" button,
which writes the form information to a Database.  When
the user visits the page again, the action builds a
DTO that contains all the information they had filled
out and puts it in the session scope, then forwards to
the JSP page that has the form on it.

I had been using the value property of the struts-html
tags to fill in the data, but I've noticed that when
the user hits submit, if there is a validation error,
they are pushed back to the page, and the data they
had enetered is replaced with what was in the DTO
(which is now old data).  I've also run into the
problem of filling in things like radio buttons, based
on what was in the DTO.

It seems to me that what I want to do is not pass
along the DTO with the action, but fill out parts of
the Form Bean before forwarding to the page that
displays it, at which point I could remove the value
properties of the html tags, and have everything work.

My question is, how can I do this from the action?  Or
do I want to attack this problem in another way?

Thanks!

__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

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