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

(-)Select.orig (-34 / +34 lines)
Lines 3-9 Link Here
3
 *
3
 *
4
 * The Apache Software License, Version 1.1
4
 * The Apache Software License, Version 1.1
5
 *
5
 *
6
 * Copyright (c) 1999 The Apache Software Foundation.  All rights 
6
 * Copyright (c) 1999 The Apache Software Foundation.  All rights
7
 * reserved.
7
 * reserved.
8
 *
8
 *
9
 * Redistribution and use in source and binary forms, with or without
9
 * Redistribution and use in source and binary forms, with or without
Lines 11-17 Link Here
11
 * are met:
11
 * are met:
12
 *
12
 *
13
 * 1. Redistributions of source code must retain the above copyright
13
 * 1. Redistributions of source code must retain the above copyright
14
 *    notice, this list of conditions and the following disclaimer. 
14
 *    notice, this list of conditions and the following disclaimer.
15
 *
15
 *
16
 * 2. Redistributions in binary form must reproduce the above copyright
16
 * 2. Redistributions in binary form must reproduce the above copyright
17
 *    notice, this list of conditions and the following disclaimer in
17
 *    notice, this list of conditions and the following disclaimer in
Lines 19-33 Link Here
19
 *    distribution.
19
 *    distribution.
20
 *
20
 *
21
 * 3. The end-user documentation included with the redistribution, if
21
 * 3. The end-user documentation included with the redistribution, if
22
 *    any, must include the following acknowlegement:  
22
 *    any, must include the following acknowlegement:
23
 *       "This product includes software developed by the 
23
 *       "This product includes software developed by the
24
 *        Apache Software Foundation (http://www.apache.org/)."
24
 *        Apache Software Foundation (http://www.apache.org/)."
25
 *    Alternately, this acknowlegement may appear in the software itself,
25
 *    Alternately, this acknowlegement may appear in the software itself,
26
 *    if and wherever such third-party acknowlegements normally appear.
26
 *    if and wherever such third-party acknowlegements normally appear.
27
 *
27
 *
28
 * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
28
 * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
29
 *    Foundation" must not be used to endorse or promote products derived
29
 *    Foundation" must not be used to endorse or promote products derived
30
 *    from this software without prior written permission. For written 
30
 *    from this software without prior written permission. For written
31
 *    permission, please contact apache@apache.org.
31
 *    permission, please contact apache@apache.org.
32
 *
32
 *
33
 * 5. Products derived from this software may not be called "Apache"
33
 * 5. Products derived from this software may not be called "Apache"
Lines 53-59 Link Here
53
 * information on the Apache Software Foundation, please see
53
 * information on the Apache Software Foundation, please see
54
 * <http://www.apache.org/>.
54
 * <http://www.apache.org/>.
55
 *
55
 *
56
 */ 
56
 */
57
package org.apache.taglibs.input;
57
package org.apache.taglibs.input;
58
58
59
import java.util.*;
59
import java.util.*;
Lines 84-90 Link Here
84
    private String size;           // select size
84
    private String size;           // select size
85
    private List optionLabels;   // a list of option labels
85
    private List optionLabels;   // a list of option labels
86
    private List optionValues;   // a list of option values
86
    private List optionValues;   // a list of option values
87
    
87
88
    private HashMap chosen;     // chosen options (created in doStartTag)
88
    private HashMap chosen;     // chosen options (created in doStartTag)
89
89
90
    public int doStartTag() throws JspException {
90
    public int doStartTag() throws JspException {
Lines 117-125 Link Here
117
            if ( attributesText != null ) {
117
            if ( attributesText != null ) {
118
                out.print( attributesText + " " );
118
                out.print( attributesText + " " );
119
            }
119
            }
120
            
120
121
            if ( multiple ) {
121
            if ( multiple ) {
122
                out.print( "multiple=\"true\" " );
122
                out.print( "multiple=\"multiple\" " );
123
            }
123
            }
124
            if ( size != null ) {
124
            if ( size != null ) {
125
                out.print( "size=\"" + Util.quote(size) + "\" " );
125
                out.print( "size=\"" + Util.quote(size) + "\" " );
Lines 138-144 Link Here
138
             */
138
             */
139
139
140
            String[] selected;
140
            String[] selected;
141
            
141
142
            // Use selected from the bean, if available
142
            // Use selected from the bean, if available
143
            String [] beanValues = ( beanId != null ? Util.beanPropertyValues(
143
            String [] beanValues = ( beanId != null ? Util.beanPropertyValues(
144
                pageContext.findAttribute( beanId ), name ) : null );
144
                pageContext.findAttribute( beanId ), name ) : null );
Lines 163-169 Link Here
163
                    }
163
                    }
164
                }
164
                }
165
            }
165
            }
166
            
166
167
            if (selected != null && selected.length > 1 &&
167
            if (selected != null && selected.length > 1 &&
168
                    ((attributes == null || !attributes.containsKey("multiple")) && !multiple))
168
                    ((attributes == null || !attributes.containsKey("multiple")) && !multiple))
169
                selected = null;
169
                selected = null;
Lines 207-220 Link Here
207
        }
207
        }
208
        return EVAL_BODY_INCLUDE;
208
        return EVAL_BODY_INCLUDE;
209
    }
209
    }
210
    
210
211
    private void outputOption( JspWriter out, Object oKey, Object oVal ) throws java.io.IOException {
211
    private void outputOption( JspWriter out, Object oKey, Object oVal ) throws java.io.IOException {
212
        String key = oKey.toString();
212
        String key = oKey.toString();
213
        /*
213
        /*
214
         * Convert the value to a String if it is not already.
214
         * Convert the value to a String if it is not already.
215
         */
215
         */
216
        String value = ( oVal != null ? oVal.toString() : null );
216
        String value = ( oVal != null ? oVal.toString() : null );
217
        
217
218
        if (value == null)
218
        if (value == null)
219
            value = key;        // use key if value is null
219
            value = key;        // use key if value is null
220
220
Lines 227-238 Link Here
227
         * (We want to match <option>s on values, not keys.)
227
         * (We want to match <option>s on values, not keys.)
228
         */
228
         */
229
        if (chosen.containsKey(value))
229
        if (chosen.containsKey(value))
230
            out.print(" selected=\"true\"");
230
            out.print(" selected=\"selected\"");
231
        out.print(">");
231
        out.print(">");
232
        out.print(Util.quote(key));
232
        out.print(Util.quote(key));
233
        out.println("</option>");
233
        out.println("</option>");
234
    }
234
    }
235
    
235
236
    public int doEndTag() throws JspException {
236
    public int doEndTag() throws JspException {
237
        try {
237
        try {
238
            JspWriter out = pageContext.getOut();
238
            JspWriter out = pageContext.getOut();
Lines 242-248 Link Here
242
        }
242
        }
243
        return EVAL_PAGE;
243
        return EVAL_PAGE;
244
    }
244
    }
245
    
245
246
    public void setName(String x) {
246
    public void setName(String x) {
247
        name = x;
247
        name = x;
248
    }
248
    }
Lines 250-260 Link Here
250
    public void setAttributes(Map x) {
250
    public void setAttributes(Map x) {
251
        attributes = x;
251
        attributes = x;
252
    }
252
    }
253
    
253
254
    public void setAttributesText( String x ) {
254
    public void setAttributesText( String x ) {
255
        attributesText = x;
255
        attributesText = x;
256
    }
256
    }
257
    
257
258
    public void setBean( String x ) {
258
    public void setBean( String x ) {
259
        beanId = x;
259
        beanId = x;
260
    }
260
    }
Lines 262-272 Link Here
262
    public void setMultiple( boolean x ) {
262
    public void setMultiple( boolean x ) {
263
        multiple = x;
263
        multiple = x;
264
    }
264
    }
265
    
265
266
    public void setSize( String x ) {
266
    public void setSize( String x ) {
267
        size = x;
267
        size = x;
268
    }
268
    }
269
    
269
270
    public void setDefault(String x) {
270
    public void setDefault(String x) {
271
        dVal = x;
271
        dVal = x;
272
    }
272
    }
Lines 274-280 Link Here
274
    public void setDefaults(String[] x) {
274
    public void setDefaults(String[] x) {
275
	dValArray = x;
275
	dValArray = x;
276
    }
276
    }
277
    
277
278
    public void setDefaults(Map x) {
278
    public void setDefaults(Map x) {
279
        dValArray = new String[ x.size() ];
279
        dValArray = new String[ x.size() ];
280
        Iterator it = x.keySet().iterator();
280
        Iterator it = x.keySet().iterator();
Lines 304-367 Link Here
304
    public void setOptionValues(List x) {
304
    public void setOptionValues(List x) {
305
        optionValues = x;
305
        optionValues = x;
306
    }
306
    }
307
    
307
308
    public HashMap getChosen() {
308
    public HashMap getChosen() {
309
        return chosen;
309
        return chosen;
310
    }
310
    }
311
    
311
312
    /** Getter for property name.
312
    /** Getter for property name.
313
     * @return Value of property name.
313
     * @return Value of property name.
314
     */
314
     */
315
    public String getName() { return name; }
315
    public String getName() { return name; }
316
    
316
317
    /** Getter for property default.
317
    /** Getter for property default.
318
     * @return Value of property default.
318
     * @return Value of property default.
319
     */
319
     */
320
    public String getDefault() { return dVal; }
320
    public String getDefault() { return dVal; }
321
    
321
322
    /** Getter for property bean.
322
    /** Getter for property bean.
323
     * @return Value of property bean.
323
     * @return Value of property bean.
324
     */
324
     */
325
    public String getBean() { return beanId; }
325
    public String getBean() { return beanId; }
326
    
326
327
    /** Getter for property attributesText.
327
    /** Getter for property attributesText.
328
     * @return Value of property attributesText.
328
     * @return Value of property attributesText.
329
     */
329
     */
330
    public String getAttributesText() { return attributesText; }
330
    public String getAttributesText() { return attributesText; }
331
    
331
332
    /** Getter for property attributes.
332
    /** Getter for property attributes.
333
     * @return Value of property attributes.
333
     * @return Value of property attributes.
334
     */
334
     */
335
    public Map getAttributes() { return attributes; }
335
    public Map getAttributes() { return attributes; }
336
    
336
337
    /** Getter for property defaults.
337
    /** Getter for property defaults.
338
     * @return Value of property defaults.
338
     * @return Value of property defaults.
339
     */
339
     */
340
    public String[] getDefaults() { return dValArray; }
340
    public String[] getDefaults() { return dValArray; }
341
    
341
342
    /** Getter for property multiple.
342
    /** Getter for property multiple.
343
     * @return Value of property multiple.
343
     * @return Value of property multiple.
344
     */
344
     */
345
    public boolean isMultiple() { return multiple; }
345
    public boolean isMultiple() { return multiple; }
346
    
346
347
    /** Getter for property optionLabels.
347
    /** Getter for property optionLabels.
348
     * @return Value of property optionLabels.
348
     * @return Value of property optionLabels.
349
     */
349
     */
350
    public List getOptionLabels() { return optionLabels; }
350
    public List getOptionLabels() { return optionLabels; }
351
    
351
352
    /** Getter for property optionValues.
352
    /** Getter for property optionValues.
353
     * @return Value of property optionValues.
353
     * @return Value of property optionValues.
354
     */
354
     */
355
    public List getOptionValues() { return optionValues; }
355
    public List getOptionValues() { return optionValues; }
356
    
356
357
    /** Getter for property options.
357
    /** Getter for property options.
358
     * @return Value of property options.
358
     * @return Value of property options.
359
     */
359
     */
360
    public Map getOptions() { return options; }
360
    public Map getOptions() { return options; }
361
    
361
362
    /** Getter for property size.
362
    /** Getter for property size.
363
     * @return Value of property size.
363
     * @return Value of property size.
364
     */
364
     */
365
    public String getSize() { return size; }
365
    public String getSize() { return size; }
366
    
366
367
}
367
}
(-)Select.orig (-2 / +2 lines)
Lines 119-125 Link Here
119
            }
119
            }
120
            
120
            
121
            if ( multiple ) {
121
            if ( multiple ) {
122
                out.print( "multiple=\"true\" " );
122
                out.print( "multiple=\"multiple\" " );
123
            }
123
            }
124
            if ( size != null ) {
124
            if ( size != null ) {
125
                out.print( "size=\"" + Util.quote(size) + "\" " );
125
                out.print( "size=\"" + Util.quote(size) + "\" " );
Lines 227-233 Link Here
227
         * (We want to match <option>s on values, not keys.)
227
         * (We want to match <option>s on values, not keys.)
228
         */
228
         */
229
        if (chosen.containsKey(value))
229
        if (chosen.containsKey(value))
230
            out.print(" selected=\"true\"");
230
            out.print(" selected=\"selected\"");
231
        out.print(">");
231
        out.print(">");
232
        out.print(Util.quote(key));
232
        out.print(Util.quote(key));
233
        out.println("</option>");
233
        out.println("</option>");

Return to bug 25497