struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sandeep Takhar <sandeep_tak...@yahoo.com>
Subject Re: where does a form element get and put it's data
Date Wed, 02 Jul 2003 20:24:15 GMT
If the page is editable, then you should have the form
as the "bean" in the list action.

It is easier to think of the whole thing as layers of
systems.  For struts - the entity that we populate
into and is auto-populated is the form.  From here we
can populate DTO's or a middle-tier object that can
eventually used by the back-end.

You may want to consider using
beanUtils.copyProperties to ease the moving of data
from the form to the DTO.

You may want to consider using XDoclet or DynaForms to
ease the burden of creating all the forms.  I would be
careful about coding too much in XDoclet for the
back-end to know too much about the front-end though. 
If it is a generic form-bean with coarse-grained
attributes that would be ok.

sandeep
--- Heather Buch <hbuch@www.thebuchs.dk> wrote:
> I know the Struts form bean raises a lot of
> discussion. Personally, form beans
> cause me a lot of confusion too, maybe not in the
> same way that they confuse
> others, but maybe so. I'll attempt to explain.
> 
> I feel like it is not consistent whether a form bean
> is first used upon
> creating, or submitting a form.
> 
> Basically, my Action classes fall into two general
> categories:
> 
> 1. "list" action classes which get data from my
> database and put it into a form.
> 2. "save" action classes which take data from the
> form and write to the db.
> 
> As far as I am concerned, this is how use of a form
> bean makes sense to me:
> 
> 1. user requests a form
> 2. "list" action executes and saves some database
> data into a the session or
> request.
> 3. user fills out and submits form
> 4. form bean collects data
> 5. "save" action executes and gets data out of form
> bean
> 
> But sometimes I feel like struts intends for me to
> use a form bean like this:
> 
> 1. user requests a form
> 2. "list" action executes and saves some database
> data into a the session or
> request.
> 3. "list" action creates a form bean and puts data
> into it (I don't like this.
> I don't want to see my form bean until after form is
> submitted)
> 4. user fills out and submits form
> 5. form bean collects data
> 6. "save" action executes and gets data out of form
> bean
> 
> I cannot understand how some of the jsp tags work
> vis a vis form beans.
> 
> For example, if, in a "list" action, I make a list
> of beans of database
> information and set that list in the session, I can
> then use the "html:select"
> tag to retrieve data from the bean I have set in the
> session, and write it to
> the form bean. This makes sense.
> 
> However, if I want to use a prepopulated radio
> button, then, in my "list"
> action I have to get data from the database and put
> it in my *form bean*.
> Based on what I understand, the html:radio
> "property" attribute will only
> prepopulate the radio button if the information
> retrieved from the *form bean*
> via "property" matches the "value" attribute of
> html:radio. But I do not want
> to *retrieve* infromation from my form bean when I
> display my form. I want to
> retrieve information from the bean that my "list"
> action has saved in the
> session. I only want to retrieve information from my
> form bean during my
> "save" action. 
> 
> so it seems like the flow of information from
> database to form bean and then
> to action is kind of inconsistent. I hope this makes
> sense. If  you need some
> examples, let me know and I'll try to create them.
> 
> Best,
> 
> Heather Buch
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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


Mime
View raw message