Author: mrdon Date: Sun Sep 2 19:39:34 2007 New Revision: 572216 URL: http://svn.apache.org/viewvc?rev=572216&view=rev Log: Fixed selection of radio item when value is null WW-2045
Added: struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Radio-4.txt Modified: struts/struts2/trunk/core/src/main/resources/template/simple/radiomap.ftl struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/RadioTest.java Modified: struts/struts2/trunk/core/src/main/resources/template/simple/radiomap.ftl URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/template/simple/radiomap.ftl?rev=572216&r1=572215&r2=572216&view=diff ============================================================================== --- struts/struts2/trunk/core/src/main/resources/template/simple/radiomap.ftl (original) +++ struts/struts2/trunk/core/src/main/resources/template/simple/radiomap.ftl Sun Sep 2 19:39:34 2007 @@ -37,7 +37,7 @@ name="${parameters.name?html}"<#rt/> </#if> id="${parameters.id?html}${itemKeyStr?html}"<#rt/> -<#if tag.contains(parameters.nameValue, itemKeyStr)> +<#if tag.contains(parameters.nameValue?default(''), itemKeyStr)> checked="checked"<#rt/> </#if> <#if itemKey?exists> Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/RadioTest.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/RadioTest.java?rev=572216&r1=572215&r2=572216&view=diff ============================================================================== --- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/RadioTest.java (original) +++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/RadioTest.java Sun Sep 2 19:39:34 2007 @@ -75,6 +75,28 @@ verify(RadioTag.class.getResource("Radio-2.txt")); } + + public void testMapCheckedNull() throws Exception { + TestAction testAction = (TestAction) action; + testAction.setFoo("bar"); + + HashMap map = new HashMap(); + map.put("1", "One"); + map.put("2", "Two"); + testAction.setMap(map); + + RadioTag tag = new RadioTag(); + tag.setPageContext(pageContext); + tag.setLabel("mylabel"); + tag.setName("myname"); + tag.setValue("%{map['3']}"); + tag.setList("[EMAIL PROTECTED]@{\"1\":\"One\", \"2\":\"Two\", \"\":\"N/A\"}"); + + tag.doStartTag(); + tag.doEndTag(); + + verify(RadioTag.class.getResource("Radio-4.txt")); + } public void testSimple() throws Exception { TestAction testAction = (TestAction) action; Added: struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Radio-4.txt URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Radio-4.txt?rev=572216&view=auto ============================================================================== --- struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Radio-4.txt (added) +++ struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Radio-4.txt Sun Sep 2 19:39:34 2007 @@ -0,0 +1,8 @@ +<tr> + <td class="tdLabel"><label for="myname" class="label">mylabel:</label></td> + <td> +<input type="radio" name="myname" id="myname2" value="2"/><label for="myname2">Two</label> +<input type="radio" name="myname" id="myname1" value="1"/><label for="myname1">One</label> +<input type="radio" name="myname" id="myname" checked="checked" value=""/><label for="myname">N/A</label> + </td> +</tr>