This doesn't show how to use optionsCollection, but I this is how I solved a
similar problem with <html:options>.

I've got a Patient, who has an address.  The Address has a String state.
I've got a collection of States, which I want to have be a <select>, and I
want the default one to be the one who's value matches the state field on
the Address from my Patient.


<jsp:useBean id="patient"  scope="request"  class="com.mycompany.Patient" />
<jsp:useBean id="states"   scope="request"  class="java.util.Collection" />
<bean:define id="address"  name="patient"   
        property="homeAddress" 
        type="com.mycompany.Address"/>

<html:select name="address" property="state">
        <html:options collection="states" property="stateId"
labelProperty="stateName"/>
</html:select>


This works for me.  Note that 'property="state"' and 'property="stateId"'
match for one of the given beans in the collection.  So that one is my
default.

Hope this helps.



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Thursday, April 03, 2003 11:17 AM
To: [EMAIL PROTECTED]
Subject: help with <html:select> and<html:optionsCollection>


I am completely new to the stuts and i am trying to display values from the
database using the <html:select> tag. I have a method called getItems in a
Form bean blah.java that returns a list of the items from the database. Item
is a database table that has different fields in it. I am using Torque that
generates the om classes for the database tables. I am trying to put the
values of a particular field from the database into the <html:select>.
Please help with this...



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