View | Details | Raw Unified | Return to bug 11992
Collapse All | Expand All

(-)Select.java (-6 / +24 lines)
Lines 74-80 Link Here
74
public class Select extends TagSupport {
74
public class Select extends TagSupport {
75
75
76
    private String name;        // name of the select element
76
    private String name;        // name of the select element
77
    private String dVal;        // default value if none is found
77
    private Vector dVals;        // default value if none is found
78
    private Map attributes;     // attributes of the <select> element
78
    private Map attributes;     // attributes of the <select> element
79
    private Map options;        // what are our options? :)
79
    private Map options;        // what are our options? :)
80
80
Lines 86-93 Link Here
86
        attributes = x;
86
        attributes = x;
87
    }
87
    }
88
88
89
    public void setDefault(String x) {
89
   public void setDefault(String x) {
90
        dVal = x;
90
	if (dVals == null)
91
	    dVals = new Vector();
92
	if (x != null)
93
	    dVals.add(x);
94
    }
95
96
    /**
97
     *  Acts more as an additive function than a normal accessor.
98
     *  (I'd call this addDefaults if I could.)
99
     */
100
    public void setDefaults(String[] x) {
101
	if (dVals == null)
102
	    dVals = new Vector();
103
	if (x != null)
104
	    for (int i = 0; i < x.length; i++)
105
		dVals.add(x[i]);
91
    }
106
    }
92
107
93
    public void setOptions(Map x) {
108
    public void setOptions(Map x) {
Lines 164-173 Link Here
164
                     * this option pair with the KEY of the 'chosen' Map
179
                     * this option pair with the KEY of the 'chosen' Map
165
                     * (We want to match <option>s on values, not keys.)
180
                     * (We want to match <option>s on values, not keys.)
166
                     */
181
                     */
182
                 for (int d = 0; d < dVals.size(); d++)   {
167
                    if ((selected != null && chosen.containsKey(value))
183
                    if ((selected != null && chosen.containsKey(value))
168
                            || (selected == null && dVal != null &&
184
                            || (selected == null && dVals != null &&
169
                            value.equals(dVal)))
185
                            ((String) dVals.get(d)).equals(value)))
170
                        out.print(" selected=\"selected\"");
186
                        out.print(" selected=\"true\"");
187
                                                          
188
                }
171
                    out.print(">");
189
                    out.print(">");
172
                    out.print(Util.quote(key));
190
                    out.print(Util.quote(key));
173
                    out.println("</option>");
191
                    out.println("</option>");

Return to bug 11992