Bug 7668 - Custom-ordered options in Select dropdown
Summary: Custom-ordered options in Select dropdown
Status: CLOSED INVALID
Alias: None
Product: Taglibs
Classification: Unclassified
Component: Input Taglib (show other bugs)
Version: 1.0
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-04-01 19:56 UTC by Paul Turnbull
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 
order).  

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 ... />
  </input:select>

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