incubator-adffaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awi...@apache.org
Subject svn commit: r505147 - /incubator/adffaces/branches/faces-1_2-070201/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/ForEachTag.java
Date Fri, 09 Feb 2007 02:43:57 GMT
Author: awiner
Date: Thu Feb  8 18:43:56 2007
New Revision: 505147

URL: http://svn.apache.org/viewvc?view=rev&rev=505147
Log:
Catch programmer error if var is set but items is not

Modified:
    incubator/adffaces/branches/faces-1_2-070201/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/ForEachTag.java

Modified: incubator/adffaces/branches/faces-1_2-070201/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/ForEachTag.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/faces-1_2-070201/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/ForEachTag.java?view=diff&rev=505147&r1=505146&r2=505147
==============================================================================
--- incubator/adffaces/branches/faces-1_2-070201/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/ForEachTag.java
(original)
+++ incubator/adffaces/branches/faces-1_2-070201/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/ForEachTag.java
Thu Feb  8 18:43:56 2007
@@ -279,18 +279,29 @@
       pageContext.getELContext().getVariableMapper();
     if (_var != null)
     {
-      ValueExpression iterated = new IndexedValueExpression(_items,
-                                                            _currentIndex);
-      vm.setVariable(_var, iterated);
+      // Catch programmer error where _var has been set but
+      // _items has not
+      if (_items != null)
+      {
+        ValueExpression iterated = new IndexedValueExpression(_items,
+                                                              _currentIndex);
+        vm.setVariable(_var, iterated);
+      }
       
+      // Ditto (though, technically, one check for
+      // _items is sufficient, because if _items evaluated
+      // to null, we'd skip the whole loop)
       Object items = _itemsValue;
-      Object item;
-      if (items instanceof List)
-        item = ((List) items).get(_currentIndex);
-      else
-        item = Array.get(items, _currentIndex);
+      if (items != null)
+      {
+        Object item;
+        if (items instanceof List)
+          item = ((List) items).get(_currentIndex);
+        else
+          item = Array.get(items, _currentIndex);
 
-      pageContext.setAttribute(_var, item);
+        pageContext.setAttribute(_var, item);
+      }
     }
     
     if (_varStatus != null)



Mime
View raw message