mirror of
https://github.com/apache/struts.git
synced 2026-08-06 15:17:00 +00:00
Merge pull request #322 from aleksandr-m/feature/WW-4991
WW-4991 Not existing property in listValueKey throws exception
This commit is contained in:
@@ -29,9 +29,12 @@
|
||||
<#if parameters.listValueKey??>
|
||||
<#-- checks the valueStack for the 'valueKey.' The valueKey is then looked-up in the locale
|
||||
file for it's localized value. This is then used as a label -->
|
||||
<#assign itemValue = stack.findString(parameters.listValueKey)/>
|
||||
<#-- FIXME: find a better way to get the value than a call to @s.text -->
|
||||
<#assign itemValue><@s.text name="${itemValue}"/></#assign>
|
||||
<#assign valueKey = stack.findString(parameters.listValueKey)!''/>
|
||||
<#if valueKey?has_content>
|
||||
<#assign itemValue = struts.getText(valueKey) />
|
||||
<#else>
|
||||
<#assign itemValue = parameters.listValueKey />
|
||||
</#if>
|
||||
<#elseif parameters.listValue??>
|
||||
<#assign itemValue = stack.findString(parameters.listValue)/>
|
||||
<#else>
|
||||
|
||||
@@ -70,8 +70,8 @@
|
||||
<#if parameters.listValueKey??>
|
||||
<#-- checks the valueStack for the 'valueKey.' The valueKey is then looked-up in the locale file for it's
|
||||
localized value. This is then used as a label -->
|
||||
<#assign valueKey = stack.findString(parameters.listValueKey) />
|
||||
<#if valueKey??>
|
||||
<#assign valueKey = stack.findString(parameters.listValueKey)!'' />
|
||||
<#if valueKey?has_content>
|
||||
<#assign itemValue = struts.getText(valueKey) />
|
||||
<#else>
|
||||
<#assign itemValue = parameters.listValueKey />
|
||||
|
||||
@@ -196,6 +196,21 @@ public class RadioTest extends AbstractUITagTest {
|
||||
verify(RadioTag.class.getResource("Radio-7.txt"));
|
||||
}
|
||||
|
||||
public void testNotExistingListValueKey() throws Exception {
|
||||
RadioTag tag = new RadioTag();
|
||||
tag.setName("myname");
|
||||
tag.setLabel("mylabel");
|
||||
tag.setList("#{'a':'aaa', 'b':'bbb', 'c':'ccc'}");
|
||||
tag.setListValueKey("notExistingProperty");
|
||||
|
||||
tag.setPageContext(pageContext);
|
||||
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
|
||||
verify(SelectTag.class.getResource("Radio-8.txt"));
|
||||
}
|
||||
|
||||
private void prepareTagGeneric(RadioTag tag) {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("bar");
|
||||
|
||||
@@ -637,6 +637,21 @@ public class SelectTest extends AbstractUITagTest {
|
||||
verify(SelectTag.class.getResource("Select-13.txt"));
|
||||
}
|
||||
|
||||
public void testNotExistingListValueKey() throws Exception {
|
||||
SelectTag tag = new SelectTag();
|
||||
tag.setName("foo");
|
||||
tag.setLabel("mylabel");
|
||||
tag.setList("#{'a':'aaa', 'b':'bbb', 'c':'ccc'}");
|
||||
tag.setListValueKey("notExistingProperty");
|
||||
|
||||
tag.setPageContext(pageContext);
|
||||
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
|
||||
verify(SelectTag.class.getResource("Select-16.txt"));
|
||||
}
|
||||
|
||||
public class IdName {
|
||||
private String name;
|
||||
private Integer id;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<tr>
|
||||
<td class="tdLabel"><label for="myname" class="label">mylabel:</label></td>
|
||||
<td class="tdInput">
|
||||
<input type="radio" name="myname" id="mynamea" value="a"/><label for="mynamea">notExistingProperty</label>
|
||||
<input type="radio" name="myname" id="mynameb" value="b"/><label for="mynameb">notExistingProperty</label>
|
||||
<input type="radio" name="myname" id="mynamec" value="c"/><label for="mynamec">notExistingProperty</label>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -0,0 +1,10 @@
|
||||
<tr>
|
||||
<td class="tdLabel"><label for="foo" class="label">mylabel:</label></td>
|
||||
<td class="tdInput">
|
||||
<select name="foo" id="foo">
|
||||
<option value="a">notExistingProperty</option>
|
||||
<option value="b">notExistingProperty</option>
|
||||
<option value="c">notExistingProperty</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
Reference in New Issue
Block a user