diff --git a/core/src/main/resources/template/simple/radiomap.ftl b/core/src/main/resources/template/simple/radiomap.ftl index e0a583892..bcd7048e8 100644 --- a/core/src/main/resources/template/simple/radiomap.ftl +++ b/core/src/main/resources/template/simple/radiomap.ftl @@ -37,7 +37,7 @@ name="${parameters.name?html}"<#rt/> id="${parameters.id?html}${itemKeyStr?html}"<#rt/> -<#if tag.contains(parameters.nameValue, itemKeyStr)> +<#if tag.contains(parameters.nameValue?default(''), itemKeyStr)> checked="checked"<#rt/> <#if itemKey?exists> diff --git a/core/src/test/java/org/apache/struts2/views/jsp/ui/RadioTest.java b/core/src/test/java/org/apache/struts2/views/jsp/ui/RadioTest.java index c66c97e36..640a4673a 100644 --- a/core/src/test/java/org/apache/struts2/views/jsp/ui/RadioTest.java +++ b/core/src/test/java/org/apache/struts2/views/jsp/ui/RadioTest.java @@ -75,6 +75,28 @@ public class RadioTest extends AbstractUITagTest { 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("#@java.util.HashMap@{\"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; diff --git a/core/src/test/resources/org/apache/struts2/views/jsp/ui/Radio-4.txt b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Radio-4.txt new file mode 100644 index 000000000..34e8dc89e --- /dev/null +++ b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Radio-4.txt @@ -0,0 +1,8 @@ + + + + + + + +