Bug 7668

Summary: Custom-ordered options in Select dropdown
Product: Taglibs Reporter: Paul Turnbull <paul_r_turnbull>
Component: Input TaglibAssignee: Tomcat Developers Mailing List <dev>
Severity: enhancement    
Priority: P3    
Version: 1.0   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Paul Turnbull 2002-04-01 19:56:05 UTC
This issue is with regard to the "Select" tag, and the order of its options.  
My requirements call for a specific order for the options that is not necessary 
ascending (or even descending).  Instead, the order of options needs to be 
mandated by the order that I add the elements to my "options" Collection.  To 
the best of my knowledge, Arrays and Vectors are the only Collection objects 
that make this guarantee (i.e. no derivations of the Map object guarantee 

To achieve this, I leveraged your existing code for the Select class, but in 
place of the Map object for options I used a Vector of simple "KeyValuePair" 
objects.  This bean-like object contains two attributes (Key and Value), and 
the appropriate getters and setters.

Is there another (e.g. easier/cleaner) way to accomplish a guaranteed custom 
order of options?

Thanks in advance for your help.
Comment 1 Shawn Bayern 2002-04-01 20:00:41 UTC
Hi Paul.

The order is up to the HashMap.  You can use a HashMap that preserves entry 
order.  One such Map (I believe it's called LinkedHashMap or SequencedHashMap) 
is available from Jakarta Commons.

I'd ideally like to support a syntax like

  <input:select ...>
    <input:option ... />

but since I'm focused on JSTL these days, I haven't had a chance to review the 
Input Taglib.