Hi Viji,

I was just playing with that today. Here's my code snippets that should help you.

From inside my extended Action class

...execute(...) {
List businesses = getUserService().getBusinesses(); // go lookup database and list all the businesses.
request.setAttribute("businesses", businesses); // save it in the request so the jsp can access it later.
return mapping.findForward("Success");
}


the List named 'businesses' is actually an ArrayList of BusinessView, which is a javabean with the following interesting fields
1. long id
2. String name;


and then, from inside my jsp
    <tr>
      <td>Business owner</td>
      <td>
        <html:select property="owner">
          <html:optionsCollection name="businesses"
                                  label="name"
                                  value="id"/>
        </html:select>
      </td>
    </tr>

checkout http://struts.apache.org/userGuide/struts-html.html#select
and http://struts.apache.org/userGuide/struts-html.html#optionsCollection
for more info.

Does combobox mean you can select mutliple entries? if so you can probably add multiple="true" attribute to the <html:select> element.

cya,
Jurn

At 02:37 PM 3/09/2004, viji.george wrote:
can anybody send me a code sample for using <html:optionCollection> for getting the value from the ArrayList and populating the combo box.

I am storing the values retrieved from the DB in a arraylist in the form of a class which has 2 attributes one for option value and the other for text of the option.

I want to put these values into the combo box.
has anybody done this?


Viji George Information Systems, The Arvind Mills Ltd., Naroda, Ahmedabad. Phone-(079)22203030 Ext -2352 <mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]


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



Reply via email to