You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chetan Pandey <cp...@BLUEsingapore.com> on 2006/07/24 06:57:24 UTC

HTML Tags for JComboBox

Hi List:

I am using a JComboBox in the following manner:

<tr>
<td><bean:message key="attendee.holidexCode"/>:</td>
<td>
<html:select property="attendeeVO.holidexCode" >
<html:options name="holidexCodeVector" /> 
</html:select>
</td>
</tr> 


Where holidexCodeVector is a Vector of Strings ( e.g. "BLUES", "IHG",
"SINGTEL" etc )

I only want the index of the chosen item, not the String.

For examples if User chose "IHG" I should get integer 1 , not the String
"IHG"

How is this possible as the underlying data structure is a "int" not String.

Thanks.

Chetan




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


Re: HTML Tags for JComboBox

Posted by Paul Benedict <pa...@yahoo.com>.
Chetan,

Hmmm.. Usually when you want to use a combo box, you provide both the value and the label for each item. Struts has a class called LabelValueBean; use this to assign the value to each label. Then pass in the array/list of LabelValueBean into <html:options> or <html:optionsCollections>.

Struts cannot magically determine what values you want. So in this instance it is using the label as the value (and vice-versa) because that's all you specified. To get the index, do what I described above -- values cannot be guessed at; you have to supply them.

Paul

Chetan Pandey <cp...@BLUEsingapore.com> wrote: Hi List:

I am using a JComboBox in the following manner:


:


 


 


Where holidexCodeVector is a Vector of Strings ( e.g. "BLUES", "IHG",
"SINGTEL" etc )

I only want the index of the chosen item, not the String.

For examples if User chose "IHG" I should get integer 1 , not the String
"IHG"

How is this possible as the underlying data structure is a "int" not String.

Thanks.

Chetan




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



 			
---------------------------------
See the all-new, redesigned Yahoo.com.  Check it out.