struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject svn commit: r1484461 - /struts/struts2/trunk/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/RadioHandler.java
Date Mon, 20 May 2013 12:59:25 GMT
Author: lukaszlenart
Date: Mon May 20 12:59:25 2013
New Revision: 1484461

URL: http://svn.apache.org/r1484461
Log:
WW-3676 Uses simple toString() for non-null objects to support other types than String and
Integer

Modified:
    struts/struts2/trunk/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/RadioHandler.java

Modified: struts/struts2/trunk/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/RadioHandler.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/RadioHandler.java?rev=1484461&r1=1484460&r2=1484461&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/RadioHandler.java
(original)
+++ struts/struts2/trunk/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/RadioHandler.java
Mon May 20 12:59:25 2013
@@ -33,8 +33,8 @@ import java.util.Iterator;
 import java.util.Map;
 
 public class RadioHandler extends AbstractTagHandler implements TagGenerator {
-    public void generate() throws IOException {
 
+    public void generate() throws IOException {
         Map<String, Object> params = context.getParameters();
 
         Object listObj = params.get("list");
@@ -59,19 +59,12 @@ public class RadioHandler extends Abstra
                 Object itemValue = findValue(listValue != null ? listValue : "top");
                 String itemValueStr = StringUtils.defaultString(itemValue == null ? null
: itemValue.toString());
 
-                //Namevalue needs to cast to a string from object. It's object because the

-                //Property can be defined as String or as Integer
-                String itemNameValueStr;
-                if (nameValue instanceof java.lang.Integer || nameValue instanceof java.lang.String)
-                    itemNameValueStr = nameValue.toString();
-                else
-                    itemNameValueStr = null;
+                // nameValue needs to cast to a string from object
+                String itemNameValueStr = (nameValue == null ? null : nameValue.toString());
 
                 //Checked value.  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.
-                Boolean checked = itemKeyStr != null &&
-                        itemNameValueStr != null &&
-                        itemNameValueStr.equals(itemKeyStr);
+                Boolean checked = itemKeyStr != null && itemNameValueStr != null
&& itemNameValueStr.equals(itemKeyStr);
 
                 //Radio button section
                 String id = params.get("id") + Integer.toString(cnt++);
@@ -93,11 +86,13 @@ public class RadioHandler extends Abstra
                         .addIfExists("style", params.get("cssStyle"))
                         .addIfExists("title", params.get("title"));
                 super.start("label", a);
-                if (StringUtils.isNotEmpty(itemValueStr))
+                if (StringUtils.isNotEmpty(itemValueStr)) {
                     characters(itemValueStr);
+                }
                 super.end("label");
                 stack.pop();
             }
         }
     }
+
 }



Mime
View raw message