From f88805221f9fcdcaf3c2d95e0ec3ef673fab7fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Gielen?= Date: Tue, 12 Feb 2008 16:05:59 +0000 Subject: [PATCH] WW-2482: Fix Freemarker exception when model list entry has null value field git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@620838 13f79535-47bb-0310-9956-ffa450edef68 --- core/src/main/resources/template/simple/checkboxlist.ftl | 4 ++-- .../org/apache/struts2/views/jsp/ui/CheckboxListTest.java | 3 ++- .../org/apache/struts2/views/jsp/ui/CheckboxList-1.txt | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/src/main/resources/template/simple/checkboxlist.ftl b/core/src/main/resources/template/simple/checkboxlist.ftl index d3d944fb6..c96c3f57c 100644 --- a/core/src/main/resources/template/simple/checkboxlist.ftl +++ b/core/src/main/resources/template/simple/checkboxlist.ftl @@ -30,7 +30,7 @@ <#assign itemKey = stack.findValue('top')/> <#if parameters.listValue?exists> - <#assign itemValue = stack.findString(parameters.listValue)/> + <#assign itemValue = stack.findString(parameters.listValue)?default("")/> <#else> <#assign itemValue = stack.findString('top')/> @@ -52,4 +52,4 @@ <#else>   - \ No newline at end of file + diff --git a/core/src/test/java/org/apache/struts2/views/jsp/ui/CheckboxListTest.java b/core/src/test/java/org/apache/struts2/views/jsp/ui/CheckboxListTest.java index d7d8bcbbe..0485941f7 100644 --- a/core/src/test/java/org/apache/struts2/views/jsp/ui/CheckboxListTest.java +++ b/core/src/test/java/org/apache/struts2/views/jsp/ui/CheckboxListTest.java @@ -140,7 +140,8 @@ public class CheckboxListTest extends AbstractUITagTest { testAction.setFoo("hello"); testAction.setList(new String[][]{ {"hello", "world"}, - {"foo", "bar"} + {"foo", "bar"}, + {"baz", null} }); CheckboxListTag tag = new CheckboxListTag(); diff --git a/core/src/test/resources/org/apache/struts2/views/jsp/ui/CheckboxList-1.txt b/core/src/test/resources/org/apache/struts2/views/jsp/ui/CheckboxList-1.txt index 7edb0d323..5b8a5b67b 100644 --- a/core/src/test/resources/org/apache/struts2/views/jsp/ui/CheckboxList-1.txt +++ b/core/src/test/resources/org/apache/struts2/views/jsp/ui/CheckboxList-1.txt @@ -5,5 +5,7 @@ + +