Bug 24850

Summary: select keys and values inversion
Product: Taglibs Reporter: Patrice Gadeyne <pgadeyne>
Component: Input TaglibAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P3    
Version: 1.1   
Target Milestone: ---   
Hardware: Other   
OS: other   

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
label.".
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>
        </select>
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.