Laurie Harper wrote:
Tom Holmes Jr. wrote:
I've created numerous pages with multiple combo-dropdown boxes that captured the label and value of a select box.
The formbean for these was always clear cut and simple.

Now, I have a select like the following:
<select name="test" multiple="true">
   <option value="selection a">A</option>
   <option value="selection b">B</option>
   <option value="selection c">C</option>
</select>
As I understand it, when I submit, this will submit back a string array (String[] test) which is defined in my form bean ... right?

Now lets say I have the following single select
<select name="test">
   <option value="selection a">A</option>
   <option value="selection b">B</option>
   <option value="selection c">C</option>
</select>
<select name="test">
   <option value="selection d">D</option>
   <option value="selection e">E</option>
   <option value="selection f">F</option>
</select>
So now there are two with the same name ... I am guessing that I will still get back a string array (String[] test) which is defined in my form bean ... right?

What I'd really like is a little different. I'd like the first selection test to be test[0] = A,B, or C (since it is single select) AND I'd like the second selection test to be test[1] = D,E, or F (since it is single select)
Or even better yet:
I'd like the first selection test to be test["first_letter"] = A,B, or C (since it is single select) AND I'd like the second selection test to be test["second_letter"] = D,E, or F (since it is single select)

So, how would I setup the form bean for this?
The way it is setup now, I have a Collection for test, and it comes back with an argument type mismatch.

Any help would be much appreciated, and I will keep working on this.
Thanks!

You're on the right lines; you need a Map rather than a Collection if you want key indexing. Your select's name would be test["a"] for the first, test["b"] for the second, etc.

L.

Laurie, thanks for thelp, but can you be of more help .... I'm been working for the last two days, and I am close, but not that close ... I did have my formBean set with HashMap loaded with data which I think is right.

I am going through an iteration loop and that buils my labels which is just text ... so label_a, label_b, label_c etc. Headers contains all my labels that I want on the page. (abel_a, label_b, label_c etc.)
<logic:iterate id="header" name="myFormBean" property="headers">
My labels are being written out with:  <bean:write name="header">
This works all good.

Within that loop I have an <html:select name="myFormBean" property="mapping" indexed='<bean:write name="header'>"> And when I look at the page, I do see <select name="mapping"> so I am not sure if this is truly being indexed the way I want.

So now I have a Collection/ArrayList of LabelValueBeans ... this collection is used to populate the drop-down box, and with: <html:optionsCollection name="properties" /> this works great. And "properties" is a property within the form bean.

The problem again is that for the first select box: label_a: mapping["a"] = single selection for combo-box a and the second select box: label_b: mapping["b"] = single selection for combo-box b

if I have explained this correctly, I know I have seen how a single select can be created so we populate a combo-box and even get the selected for it. And now I have multiple select boxes indexed with a name (same name as the label/header) and I want to get the single "selected." within the combo-box. So, how I define that structure within my form bean is important, then I can populate that structure in my pre-action class ... And then when I submit it ... I don't want to get an argument-type-mismatch within the beanutils.populate when I submit the JSP page.

Thanks again for the help. I will keep working on this also. Tom


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

Reply via email to