Although, I don't really see a major problem with storing the options in the
form itself (just to make things simple).  Anybody have a compelling reason
NOT to do this?

i.e. I put my statesCollection as a property on my ActionForm with a List
datatype.  Then I can just use the form property to populate my options.

worse is better 

-----Original Message-----
From: Hubert Rabago [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, November 18, 2003 6:10 PM
To: Struts Users Mailing List
Subject: Re: Form data vs request attributes



ActionForm objects are representation of a form and the data in the form. It
holds the values of your <INPUT>, <SELECT>, <TEXTAREA> and other form
controls.

The options of a <SELECT> control are only used to help the user choose a 
value; its only purpose is to give the <SELECT> control a value and isn't
itself a value of the form.  Think of it this way: the form doesn't lose any
data by changing your <SELECT> into an <INPUT type=text>.  
Confused?  Think of it another way: The <OPTION> values don't get submitted,
only the value of the <SELECT>.

So:
1) The ActionForm helps you get to the values submitted with the form, and
so "suburb" is required there because it's part of the form.
2) The ActionForm doesn't hold <OPTION> values, only the value of the
<SELECT>.
3) You need a way to tell <html:options> what to show, and you can do it by
specifying a collection that's in scope (doesn't have to be the request
scope).

Hope all that didn't confuse you further.  


--- Craig Edwards <[EMAIL PROTECTED]> wrote:
> I've been fiddling around with Struts for a while now and am still a
> little puzzled as to whether JSPs should be getting their data from my 
> DynaActionForm or from the session/request context.  For example, if my 
> JSP contains:
> 
> <html:select property="selectedCustomer" size="5">
>   <html:options collection="customers" property="id"/> </html:select>
> <html:text property="suburb" size="16" maxlength="18"/>
> 
> The way I have this working currently is by adding "customers" to the
> request context and by having "suburb" declared in my DynaActionForm.  I 
> don't appear to have to declare "customers" in the form, but if I don't 
> declare "suburb", I get an error... what is the difference?
> 
> P.S.  If it helps clarify things, the JSP I have displays a list of
> customers and some input fields.  The user can update the input fields, 
> press submit and they see the same page (with the new details displayed 
> in the list).  Many thanks.
> 
> --
> Craig Edwards
> Sydney, Australia
> 


__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

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

Reply via email to