mirror of
https://github.com/apache/struts.git
synced 2026-08-11 09:36:57 +00:00
Fixed selection of radio item when value is null
WW-2045 git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@572216 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user