I see two primary options ...
(1) use a TreeMap instead of a Hashtable 
However, to me this be unnecessary if the sorting is purely for presentation
purposes, or
(2) Create a JavaBean that holds two lists ... one for the option values and
one for the option labels ... sorted according to the labels.

I have done this on numerous occasions where I have a collection of things
that contain IDs for use as values and then names for use as labels ...
Basically, I first sort the collection according to the field I want
(typically, I do this using a Comparator) then I create two lists one for
the values and one for the labels.

Of course, if you are accessing the data from a database and can do the
sorting there it is preferable then sorting in the middle tier.

BTW, I am using Struts 1.0 -- there may be features in the nightly build
that make this easier.

-----Original Message-----
From: Sue Deng [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 14, 2001 3:20 PM
To: [EMAIL PROTECTED]
Subject: How to list options in order?


Hi,

I am using html:select and html:options like this:

               <html:select property="key">
                 <html:options collection="organizations" property="key"
labelProperty="value"/>
               </html:select>

The organization is a collection of Hashtable.

Is there any way I can list the options in labelProperty order?

Thanks,

-Sue


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

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

Reply via email to