struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aparna Tula" <>
Subject RE: Index of an arrayList in a options tag
Date Fri, 24 Aug 2001 17:38:20 GMT
With minimal changes, the best way is to do something like this:

      <html:select property="singleSelect" size="5">
        <html:options property="indexList" labelProperty="selectList"/>

where indexList is an array of your index values. 

The other way is to create say a collection(say, allOptions) of
"OptionLabelValue" beans. Each of this bean holds one
'option'(label-value pair). 

then in your JSP:

      <html:select property="singleSelect" size="5">
        <html:options collection="allOptions" property="value"

(They have examples in the struts-example app.)

Hope that helps!

- Aparna

-----Original Message-----
From: Ganendran Kumaraswamy []
Sent: Friday, August 24, 2001 1:28 AM
To: ''
Subject: Index of an arrayList in a options tag

Hi All,

I am using an arraylist to hold some values and display them in a select
as follows.

      <html:select property="singleSelect" size="5">
        <html:options property="selectList" labelProperty="selectList"/>

I have created the arraylist in my action class and added some values to
Then I set it to the form (to the selectList variable). Of course I have
getter and setter methods in my bean and it works fine. My question is,
I display the index of the arraylist as the value property in my option
tag ? How do I do it ? For e.g. I would ideally like the output to be

<option value="0">Some text </option>
<option value="1">Some other text</option>


View raw message