You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Mike Quentel <mq...@4dm-inc.com> on 2009/07/08 23:15:16 UTC

Sorted SelectItem objects in selectOneChoice

Using JSF 1.2 and Trinidad...

 

selectOneChoice drop down selection lists are dynamically populated from
lookup tables in a database.  An ArrayList stores SelectItem objects.

 

Does anyone know how to make selectOneChoice sorted, other than via the
actual SQL query (" ORDER BY ")?

 

I tried using some of the java.util.Collections classes, but did not get
this to work.

 

Thanks,

 

Mike Quentel

 


Re: Sorted SelectItem objects in selectOneChoice

Posted by Jacek Bilski <ja...@gmail.com>.
Hi,

Mike Quentel wrote:

> I tried using some of the java.util.Collections classes, but did not get 
> this to work.

You have to add SelectItems to list in your specific order. If you don't 
want to sort entries in your database (which would be fastest), you can 
always write Comparator (or implement Comparable) for your objects and 
then use Collections.sort().

Regards

Jacek Bilski