From 7b922cd5d5bc2885b85cda8509b7b4ef6ca243fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Gielen?= Date: Tue, 12 Feb 2008 16:07:46 +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/trunk@620841 13f79535-47bb-0310-9956-ffa450edef68 --- core/src/main/resources/template/simple/checkboxlist.ftl | 2 +- .../java/org/apache/struts2/views/jsp/ui/CheckboxListTest.java | 3 ++- .../org/apache/struts2/views/jsp/ui/CheckboxList-1.txt | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/src/main/resources/template/simple/checkboxlist.ftl b/core/src/main/resources/template/simple/checkboxlist.ftl index 9b005edfc..6f6619dde 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')/> 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 b7f4e2a28..af756d2da 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 @@ -134,7 +134,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 @@ + +