Revision: 427
          http://svn.sourceforge.net/stripes/?rev=427&view=rev
Author:   tfenne
Date:     2006-10-05 18:25:24 -0700 (Thu, 05 Oct 2006)

Log Message:
-----------
Merge of r426 (select multiple to accept booleans) to the 1.4 branch.

Modified Paths:
--------------
    branches/1.4.x/stripes/resources/stripes.tld
    branches/1.4.x/stripes/src/net/sourceforge/stripes/tag/InputSelectTag.java

Modified: branches/1.4.x/stripes/resources/stripes.tld
===================================================================
--- branches/1.4.x/stripes/resources/stripes.tld        2006-10-06 01:21:28 UTC 
(rev 426)
+++ branches/1.4.x/stripes/resources/stripes.tld        2006-10-06 01:25:24 UTC 
(rev 427)
@@ -1466,8 +1466,10 @@
         
<attribute><description>@disabled@</description><name>disabled</name><required>false</required><rtexprvalue>true</rtexprvalue></attribute>
         <attribute>
             <description>
-                The presence of this attribute will make the select render as 
a multi-select list
-                instead of a drop-down single-select widget. (HTML 
Pass-through)
+                If the value passed in matches the empty string or (ignoring 
case) "multiple",
+                or if the value can reasonably be converted to true then the 
attribute will be
+                rendered as multiple="multiple" causing the select to render 
as a multi-select.
+                In all other cases the attribute will be omitted.
             </description>
             
<name>multiple</name><required>false</required><rtexprvalue>true</rtexprvalue>
         </attribute>

Modified: 
branches/1.4.x/stripes/src/net/sourceforge/stripes/tag/InputSelectTag.java
===================================================================
--- branches/1.4.x/stripes/src/net/sourceforge/stripes/tag/InputSelectTag.java  
2006-10-06 01:21:28 UTC (rev 426)
+++ branches/1.4.x/stripes/src/net/sourceforge/stripes/tag/InputSelectTag.java  
2006-10-06 01:25:24 UTC (rev 427)
@@ -15,6 +15,7 @@
 package net.sourceforge.stripes.tag;
 
 import net.sourceforge.stripes.exception.StripesJspException;
+import net.sourceforge.stripes.validation.BooleanTypeConverter;
 
 import javax.servlet.jsp.JspException;
 import javax.servlet.jsp.tagext.BodyTag;
@@ -35,9 +36,26 @@
     private Object value;
     private Object selectedValueOrValues;
 
-    /** Sets the HTML attribute &quot;multiple&quot;. **/
-    public void setMultiple(String multiple) { set("multiple", multiple); }
+    /**
+     * If the text value passed in matches the empty string or (ignoring case) 
"multiple",
+     * or if the value can be converted to true by the [EMAIL PROTECTED] 
BooleanTypeConverter} then the
+     * attribute will be set to "multiple", otherwise the attribute will not 
be output.
+     */
+    public void setMultiple(String multiple) {
+        boolean isMultiple = "multiple".equalsIgnoreCase(multiple) || 
"".equals(multiple);
+        if (!isMultiple) {
+            BooleanTypeConverter converter = new BooleanTypeConverter();
+            isMultiple = converter.convert(multiple, Boolean.class, null);
+        }
 
+        if (isMultiple) {
+            set("multiple", "multiple");
+        }
+        else {
+            getAttributes().remove("multiple");
+        }
+    }
+
     /** Gets the HTML attribute &quot;multiple&quot;. **/
     public String getMultiple() { return get("multiple"); }
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to