Say you have 2 input fields backed by a Map named myMap:
<input type="text" name="myMap(one)" value="1"/>
<input type="text" name="myMap(one)" value="2"/>

When the form is populated the Map value for key "one" will get written twice and the last one entered will be your value.

David


From: "WILLIAMS,RAND (HP-USA,ex1)" <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: 'Struts Users Mailing List' <[EMAIL PROTECTED]>
Subject: RE: <html:select multiple="true" not working... how does it work?
Date: Wed, 19 Mar 2003 14:04:27 -0500

Hi David, thank you :)
But I'm still a bit confused.

The reason why I want to use a Map to hold these values
of the form, is that I want the flexibility of having
X number of String[], populated from the form :selects
and stored in the Map. Then I can process X String[]'s
in my Action by iterating over the Map, and doing
the appropriate stuff with the Map.Entry Key (String),
and Map.Entry Value (the String[]).

I don't understand, because it works for everything
else, including other bean objects... just not for a
String[]

for a String, there is no problem, for
property="value(myString)" beanUtils
finds and does my getValue("myString")
and the object returned is a String.

for a String[], there is a problem, for
property="value(myArray)" beanUtils
finds and does my getValue("myArray")
and the object returned is a String[0],
or null.  Is the problem that it is [0]
or null?

Are you saying is that it is overwritten by the
beanUtils use of my setValue("myArray", String[])?
Or is beanUtils using setValue("myArray", String)?

Or does beanUtils find that the returned object,
although it is a String[], is zero size - it
creates another String[_numberOfSelections] and
then uses my setValue("myArray", the new String[])
but that latter seems like it would work...

Or is it that since beanUtils cannot find an
indexed setValue(key, value, idx), it doesn't
even bother with trying to populate my String[]
(through the indexed set()) and just opt's to
set the first value of my selection (String[0])
by simply doing setValue("myArray", String[0])?
This is what it looks like it does...

Just trying to understand it... what do you think??
THANKS!!!!!
-Rand


-----Original Message----- From: David Graham [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 19, 2003 1:41 PM To: [EMAIL PROTECTED] Subject: Re: <html:select multiple="true" not working...


You can't use String[] inside a Map backed field. The value will get overwritten by the next property of the same name in the map. Use a String[] to support multi valued select boxes.

David



>From: "WILLIAMS,RAND (HP-USA,ex1)" <[EMAIL PROTECTED]>
>Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>To: 'Struts Users Mailing List' <[EMAIL PROTECTED]>
>Subject: <html:select multiple="true" not working...
>Date: Wed, 19 Mar 2003 10:08:00 -0800
>
>Anyone tried this?
>
>Using a map backed form, where
>set(key,val) { mymap.put(key,val) }
>and get(key) { return mymap.get(key) }
>
>I am having a problem with String[] and multiple attribute of html:select:
>
><html:select property="value(selectProduct)" multiple="true">
> <logic:iterate id="x" name="telecomModel" property="services" >
> <bean:define id="y" name="x" property="product" />
> <html:option value='<%=(String)y%>' />
> </logic:iterate>
></html:select>
>
>Even though value(selectProduct) gives to the tag
>[INFO] SmModelForm - - getValue(selectProduct) = [Ljava.lang.String;@deb5f
>which is a String[0]
>
>The problem i see is beanUtils still populates the field with only a
>string:
>
>[INFO] SmModelForm - - setValue(selectProduct,U3995)
>which is merely a String - not a String[] with an element (String) "U3995".
>
>Is there something wrong or am I missing something here??
>Is there an issue with retrieving or setting the String[] from a HashMap?
>
>Thanks in advance for help :)
>-Rand
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

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


_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus



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



Reply via email to