Bug 24850 - select keys and values inversion
Summary: select keys and values inversion
Alias: None
Product: Taglibs
Classification: Unclassified
Component: Input Taglib (show other bugs)
Version: 1.1
Hardware: Other other
: P3 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2003-11-20 09:51 UTC by Patrice Gadeyne
Modified: 2004-11-16 19:05 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Patrice Gadeyne 2003-11-20 09:51:09 UTC
The doc for the "options" attribute of the select tag says: 
"options map for select. The key is the option value and the value is the option
But with this code 
        <input:select name="select1" options="<%= optMap %>" />
give the following result:
        <select name="select1">
            <option value="Label1">key1</option>
            <option value="Label2">key2</option>
Which is not what I was expecting.

A second test with this code:
        <input:select name="select2" 
              optionLabels="<%= new java.util.Vector(optMap.values()) %>"
              optionValues="<%= new java.util.Vector(optMap.keySet()) %>" />
give a different results, which for me should be the default result.

Am I missing something? Because I would be quite surprised to be the first to
note such a visible bug.

For info here is the map I used:
TreeMap optMap = new TreeMap();
optMap.put("key1", "Label1");
optMap.put("key2", "Label2");
Comment 1 Karl von Randow 2004-10-26 23:02:16 UTC
You're right - the documentation is wrong. It is in fact Map key => option 
label, Map value => option value.

I have updated the documentation to reflect the actual implementation.

I'm not sure whether I feel that the implementation is the right-way-around, 
however in the interests of compatibility I don't see a problem leaving it 
with the current implementation.