struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From musa...@apache.org
Subject svn commit: r554223 - in /struts/struts2/trunk/core/src: main/java/org/apache/struts2/components/IteratorComponent.java test/java/org/apache/struts2/views/jsp/IteratorTagTest.java
Date Sat, 07 Jul 2007 15:43:52 GMT
Author: musachy
Date: Sat Jul  7 08:43:51 2007
New Revision: 554223

URL: http://svn.apache.org/viewvc?view=rev&rev=554223
Log:
WW-2024 Iterator tag does associate a value with the name specified on the "id" property when
the value is null

Modified:
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/IteratorComponent.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/IteratorTagTest.java

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/IteratorComponent.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/IteratorComponent.java?view=diff&rev=554223&r1=554222&r2=554223
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/IteratorComponent.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/IteratorComponent.java
Sat Jul  7 08:43:51 2007
@@ -248,7 +248,7 @@
 
             String id = getId();
 
-            if ((id != null) && (currentValue != null)) {
+            if (id != null) {
                 //pageContext.setAttribute(id, currentValue);
                 //pageContext.setAttribute(id, currentValue, PageContext.REQUEST_SCOPE);
                 stack.getContext().put(id, currentValue);

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/IteratorTagTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/IteratorTagTest.java?view=diff&rev=554223&r1=554222&r2=554223
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/IteratorTagTest.java
(original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/IteratorTagTest.java
Sat Jul  7 08:43:51 2007
@@ -101,6 +101,49 @@
         result = tag.doEndTag();
         assertEquals(result, TagSupport.EVAL_PAGE);
     }
+    
+    public void testIteratingWithIdSpecifiedAndNullElementOnCollection() throws Exception
{
+        List list = new ArrayList();
+        list.add("one");
+        list.add(null);
+        list.add("three");
+
+        Foo foo = new Foo();
+        foo.setList(list);
+
+        stack.push(foo);
+
+        tag.setValue("list");
+        tag.setId("myId");
+
+        // one
+        int result = tag.doStartTag();
+        assertEquals(result, TagSupport.EVAL_BODY_INCLUDE);
+        assertEquals(stack.peek(), "one");
+        assertEquals(stack.getContext().get("myId"), "one");
+
+
+        tag.doInitBody();
+
+        // two
+        result = tag.doAfterBody();
+        assertEquals(result, TagSupport.EVAL_BODY_AGAIN);
+        assertNull(stack.peek());
+        assertNull(stack.getContext().get("myId"));
+
+
+        // three
+        result = tag.doAfterBody();
+        assertEquals(result, TagSupport.EVAL_BODY_AGAIN);
+        assertEquals(stack.peek(), "three");
+        assertEquals(stack.getContext().get("myId"), "three");
+
+        result = tag.doAfterBody();
+        assertEquals(result, TagSupport.SKIP_BODY);
+
+        result = tag.doEndTag();
+        assertEquals(result, TagSupport.EVAL_PAGE);
+    }
 
 
     public void testArrayIterator() {



Mime
View raw message