|Summary:||Custom-ordered options in Select dropdown|
|Product:||Taglibs||Reporter:||Paul Turnbull <paul_r_turnbull>|
|Component:||Input Taglib||Assignee:||Tomcat Developers Mailing List <dev>|
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.