Updated Branches:
  refs/heads/master b0dee67bf -> e858e4d00

Make we sure we handle doubles/longs correctly, for class cast
exception.

Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/e858e4d0
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/e858e4d0
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/e858e4d0

Branch: refs/heads/master
Commit: e858e4d000ecca5ba628225724fdfd98b31d9e7a
Parents: b0dee67
Author: Greg Huber <[email protected]>
Authored: Mon Feb 3 10:09:22 2014 +0000
Committer: Greg Huber <[email protected]>
Committed: Mon Feb 3 10:09:22 2014 +0000

----------------------------------------------------------------------
 .../views/java/simple/CheckboxListHandler.java  | 219 ++++++++++---------
 .../struts2/views/java/simple/RadioHandler.java | 178 ++++++++-------
 2 files changed, 212 insertions(+), 185 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/e858e4d0/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/CheckboxListHandler.java
----------------------------------------------------------------------
diff --git 
a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/CheckboxListHandler.java
 
b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/CheckboxListHandler.java
index f44746d..891fee5 100644
--- 
a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/CheckboxListHandler.java
+++ 
b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/CheckboxListHandler.java
@@ -33,106 +33,123 @@ import java.io.IOException;
 import java.util.Iterator;
 import java.util.Map;
 
-public class CheckboxListHandler extends AbstractTagHandler implements 
TagGenerator {
-    public void generate() throws IOException {
-
-        Map<String, Object> params = context.getParameters();
-
-        // Get parameters
-        Object listObj = params.get("list");
-        String listKey = (String) params.get("listKey");
-        String listValue = (String) params.get("listValue");
-        String name = (String) params.get("name");
-        Object disabled = params.get("disabled");
-        String id = (String) params.get("id");
-
-        int cnt = 1;
-
-        // This will interate through all lists
-        ValueStack stack = this.context.getStack();
-        if (listObj != null) {
-            Iterator itt = MakeIterator.convert(listObj);
-            while (itt.hasNext()) {
-                Object item = itt.next();
-                stack.push(item);
-
-                // key
-                Object itemKey = findValue(listKey != null ? listKey : "top");
-                String itemKeyStr = StringUtils.defaultString(itemKey == null 
? null : itemKey.toString());
-
-                // value
-                Object itemValue = findValue(listValue != null ? listValue : 
"top");
-                String itemValueStr = StringUtils.defaultString(itemValue == 
null ? null : itemValue.toString());
-
-                // Checkbox button section
-                Attributes a = new Attributes();
-                a.add("type", "checkbox").add("name", name).add("value", 
itemKeyStr)
-                        .addIfTrue("checked", isChecked(params, itemKeyStr))
-                        .addIfTrue("readonly", 
params.get("readonly")).addIfTrue("disabled", disabled)
-                        .addIfExists("tabindex", params.get("tabindex"))
-                        .addIfExists("id", id + "-" + Integer.toString(cnt));
-                start("input", a);
-                end("input");
-
-                // Label section
-                a = new Attributes();
-                a.add("for", id + "-" + 
Integer.toString(cnt)).addIfExists("class", params.get("cssClass"))
-                        .addIfExists("style", params.get("cssStyle"));
-                super.start("label", a);
-                if (StringUtils.isNotEmpty(itemValueStr))
-                    characters(itemValueStr);
-                super.end("label");
-
-                // Hidden input section
-                a = new Attributes();
-                a.add("type", "hidden")
-                        .add("id", "__multiselect_" + 
StringUtils.defaultString(StringEscapeUtils.escapeHtml4(id)))
-                        .add("name", "__multiselect_" + 
StringUtils.defaultString(StringEscapeUtils.escapeHtml4(name)))
-                        .add("value", "").addIfTrue("disabled", disabled);
-                start("input", a);
-                end("input");
-
-                stack.pop();
-                cnt++;
-            }
-        }
-    }
-
-    /**
-     * It's set to true if the nameValue (the value associated with the name
-     * which is typically set in the action is equal to the current key value.
-     * 
-     * @param params
-     *            the params
-     * 
-     * @param itemKeyStr
-     *            the item key str
-     * 
-     * @return the boolean
-     */
-    private Boolean isChecked(Map<String, Object> params, String itemKeyStr) {
-        Boolean checked = false;
-        if (itemKeyStr != null) {
-
-            // NameValue are the values that is provided by the name property
-            // in the action
-            Object nameValue = params.get("nameValue");
-
-            if (nameValue != null) {
-
-                Iterator itt = MakeIterator.convert(nameValue);
-                while (itt.hasNext()) {
-
-                    String value = (String) itt.next();
-                    if (checked = value.equalsIgnoreCase(itemKeyStr)) {
-                        break;
-                    }
-
-                }
-
-            }
-        }
-        return checked;
-    }
+public class CheckboxListHandler extends AbstractTagHandler implements
+               TagGenerator {
+       public void generate() throws IOException {
+
+               Map<String, Object> params = context.getParameters();
+
+               // Get parameters
+               Object listObj = params.get("list");
+               String listKey = (String) params.get("listKey");
+               String listValue = (String) params.get("listValue");
+               String name = (String) params.get("name");
+               Object disabled = params.get("disabled");
+               String id = (String) params.get("id");
+
+               int cnt = 1;
+
+               // This will interate through all lists
+               ValueStack stack = this.context.getStack();
+               if (listObj != null) {
+                       Iterator itt = MakeIterator.convert(listObj);
+                       while (itt.hasNext()) {
+                               Object item = itt.next();
+                               stack.push(item);
+
+                               // key
+                               Object itemKey = findValue(listKey != null ? 
listKey : "top");
+                               String itemKeyStr = StringUtils
+                                               .defaultString(itemKey == null 
? null : itemKey
+                                                               .toString());
+
+                               // value
+                               Object itemValue = findValue(listValue != null 
? listValue
+                                               : "top");
+                               String itemValueStr = StringUtils
+                                               .defaultString(itemValue == 
null ? null : itemValue
+                                                               .toString());
+
+                               // Checkbox button section
+                               Attributes a = new Attributes();
+                               a.add("type", "checkbox").add("name", name)
+                                               .add("value", itemKeyStr)
+                                               .addIfTrue("checked", 
isChecked(params, itemKeyStr))
+                                               .addIfTrue("readonly", 
params.get("readonly"))
+                                               .addIfTrue("disabled", disabled)
+                                               .addIfExists("tabindex", 
params.get("tabindex"))
+                                               .addIfExists("id", id + "-" + 
Integer.toString(cnt));
+                               start("input", a);
+                               end("input");
+
+                               // Label section
+                               a = new Attributes();
+                               a.add("for", id + "-" + Integer.toString(cnt))
+                                               .addIfExists("class", 
params.get("cssClass"))
+                                               .addIfExists("style", 
params.get("cssStyle"));
+                               super.start("label", a);
+                               if (StringUtils.isNotEmpty(itemValueStr))
+                                       characters(itemValueStr);
+                               super.end("label");
+
+                               // Hidden input section
+                               a = new Attributes();
+                               a.add("type", "hidden")
+                                               .add("id",
+                                                               "__multiselect_"
+                                                                               
+ StringUtils
+                                                                               
                .defaultString(StringEscapeUtils
+                                                                               
                                .escapeHtml4(id)))
+                                               .add("name",
+                                                               "__multiselect_"
+                                                                               
+ StringUtils
+                                                                               
                .defaultString(StringEscapeUtils
+                                                                               
                                .escapeHtml4(name)))
+                                               .add("value", 
"").addIfTrue("disabled", disabled);
+                               start("input", a);
+                               end("input");
+
+                               stack.pop();
+                               cnt++;
+                       }
+               }
+       }
+
+       /**
+        * It's set to true if the nameValue (the value associated with the name
+        * which is typically set in the action is equal to the current key 
value.
+        * 
+        * @param params
+        *            the params
+        * 
+        * @param itemKeyStr
+        *            the item key str
+        * 
+        * @return the boolean
+        */
+       private Boolean isChecked(Map<String, Object> params, String 
itemKeyStr) {
+               Boolean checked = false;
+               if (itemKeyStr != null) {
+
+                       // NameValue are the values that is provided by the 
name property
+                       // in the action
+                       Object nameValue = params.get("nameValue");
+
+                       if (nameValue != null) {
+
+                               Iterator itt = MakeIterator.convert(nameValue);
+                               while (itt.hasNext()) {
+
+                                       String value = itt.next().toString();
+                                       if (checked = 
value.equalsIgnoreCase(itemKeyStr)) {
+                                               break;
+                                       }
+
+                               }
+
+                       }
+               }
+               return checked;
+       }
 
 }

http://git-wip-us.apache.org/repos/asf/struts/blob/e858e4d0/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/RadioHandler.java
----------------------------------------------------------------------
diff --git 
a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/RadioHandler.java
 
b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/RadioHandler.java
index 756abdc..9ff5278 100644
--- 
a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/RadioHandler.java
+++ 
b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/RadioHandler.java
@@ -34,89 +34,99 @@ import java.util.Map;
 
 public class RadioHandler extends AbstractTagHandler implements TagGenerator {
 
-    public void generate() throws IOException {
-        Map<String, Object> params = context.getParameters();
-
-        Object listObj = params.get("list");
-        String listKey = (String) params.get("listKey");
-        String listValue = (String) params.get("listValue");
-        int cnt = 0;
-
-        ValueStack stack = this.context.getStack();
-        if (listObj != null) {
-            Iterator itt = MakeIterator.convert(listObj);
-            while (itt.hasNext()) {
-                Object item = itt.next();
-                stack.push(item);
-
-                // key
-                Object itemKey = findValue(listKey != null ? listKey : "top");
-                String itemKeyStr = StringUtils.defaultString(itemKey == null 
? null : itemKey.toString());
-
-                // value
-                Object itemValue = findValue(listValue != null ? listValue : 
"top");
-                String itemValueStr = StringUtils.defaultString(itemValue == 
null ? null : itemValue.toString());
-
-                // Radio button section
-                String id = params.get("id") + Integer.toString(cnt++);
-                Attributes a = new Attributes();
-                a.add("type", "radio").addDefaultToEmpty("name", 
params.get("name"))
-                        .addIfTrue("checked", isChecked(params, 
itemKeyStr)).addIfExists("value", itemKeyStr)
-                        .addIfTrue("disabled", 
params.get("disabled")).addIfExists("tabindex", params.get("tabindex"))
-                        .addIfExists("id", id);
-                super.start("input", a);
-                super.end("input");
-
-                // Label section
-                a = new Attributes();
-                a.addIfExists("for", id).addIfExists("class", 
params.get("cssClass"))
-                        .addIfExists("style", 
params.get("cssStyle")).addIfExists("title", params.get("title"));
-                super.start("label", a);
-                if (StringUtils.isNotEmpty(itemValueStr)) {
-                    characters(itemValueStr);
-                }
-                super.end("label");
-                stack.pop();
-            }
-        }
-    }
-
-    /**
-     * It's set to true if the nameValue (the value associated with the name
-     * which is typically set in the action is equal to the current key value.
-     * 
-     * @param params
-     *            the params
-     * 
-     * @param itemKeyStr
-     *            the item key str
-     * 
-     * @return the boolean
-     */
-    private Boolean isChecked(Map<String, Object> params, String itemKeyStr) {
-        Boolean checked = false;
-        if (itemKeyStr != null) {
-
-            // NameValue are the values that is provided by the name property
-            // in the action
-            Object nameValue = params.get("nameValue");
-
-            if (nameValue != null) {
-
-                Iterator itt = MakeIterator.convert(nameValue);
-                while (itt.hasNext()) {
-
-                    String value = (String) itt.next();
-                    if (checked = value.equalsIgnoreCase(itemKeyStr)) {
-                        break;
-                    }
-
-                }
-
-            }
-
-        }
-        return checked;
-    }
+       public void generate() throws IOException {
+               Map<String, Object> params = context.getParameters();
+
+               Object listObj = params.get("list");
+               String listKey = (String) params.get("listKey");
+               String listValue = (String) params.get("listValue");
+               int cnt = 0;
+
+               ValueStack stack = this.context.getStack();
+               if (listObj != null) {
+                       Iterator itt = MakeIterator.convert(listObj);
+                       while (itt.hasNext()) {
+                               Object item = itt.next();
+                               stack.push(item);
+
+                               // key
+                               Object itemKey = findValue(listKey != null ? 
listKey : "top");
+                               String itemKeyStr = StringUtils
+                                               .defaultString(itemKey == null 
? null : itemKey
+                                                               .toString());
+
+                               // value
+                               Object itemValue = findValue(listValue != null 
? listValue
+                                               : "top");
+                               String itemValueStr = StringUtils
+                                               .defaultString(itemValue == 
null ? null : itemValue
+                                                               .toString());
+
+                               // Radio button section
+                               String id = params.get("id") + 
Integer.toString(cnt++);
+                               Attributes a = new Attributes();
+                               a.add("type", "radio")
+                                               .addDefaultToEmpty("name", 
params.get("name"))
+                                               .addIfTrue("checked", 
isChecked(params, itemKeyStr))
+                                               .addIfExists("value", 
itemKeyStr)
+                                               .addIfTrue("disabled", 
params.get("disabled"))
+                                               .addIfExists("tabindex", 
params.get("tabindex"))
+                                               .addIfExists("id", id);
+                               super.start("input", a);
+                               super.end("input");
+
+                               // Label section
+                               a = new Attributes();
+                               a.addIfExists("for", id)
+                                               .addIfExists("class", 
params.get("cssClass"))
+                                               .addIfExists("style", 
params.get("cssStyle"))
+                                               .addIfExists("title", 
params.get("title"));
+                               super.start("label", a);
+                               if (StringUtils.isNotEmpty(itemValueStr)) {
+                                       characters(itemValueStr);
+                               }
+                               super.end("label");
+                               stack.pop();
+                       }
+               }
+       }
+
+       /**
+        * It's set to true if the nameValue (the value associated with the name
+        * which is typically set in the action is equal to the current key 
value.
+        * 
+        * @param params
+        *            the params
+        * 
+        * @param itemKeyStr
+        *            the item key str
+        * 
+        * @return the boolean
+        */
+       private Boolean isChecked(Map<String, Object> params, String 
itemKeyStr) {
+               Boolean checked = false;
+               if (itemKeyStr != null) {
+
+                       // NameValue are the values that is provided by the 
name property
+                       // in the action
+                       Object nameValue = params.get("nameValue");
+
+                       if (nameValue != null) {
+
+                               Iterator itt = MakeIterator.convert(nameValue);
+                               while (itt.hasNext()) {
+
+                                       String value = itt.next().toString();
+                                       if (checked = 
value.equalsIgnoreCase(itemKeyStr)) {
+                                               break;
+                                       }
+
+                               }
+
+                       }
+
+               }
+               return checked;
+       }
 
 }

Reply via email to