myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1155050 - in /myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/model: DataModel.java ResultSetDataModel.java
Date Mon, 08 Aug 2011 18:38:55 GMT
Author: lu4242
Date: Mon Aug  8 18:38:54 2011
New Revision: 1155050

URL: http://svn.apache.org/viewvc?rev=1155050&view=rev
Log:
MYFACES-3270 DataModel.iterator cannot assume getRowCount will be always set

Modified:
    myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/model/DataModel.java
    myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/model/ResultSetDataModel.java

Modified: myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/model/DataModel.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/model/DataModel.java?rev=1155050&r1=1155049&r2=1155050&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/model/DataModel.java (original)
+++ myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/model/DataModel.java Mon Aug
 8 18:38:54 2011
@@ -174,9 +174,15 @@ public abstract class DataModel<E> imple
     {
         private int nextRowIndex = 0;
         
+        public DataModelIterator()
+        {
+            setRowIndex(nextRowIndex);
+        }
+        
         public boolean hasNext()
         {
-            return nextRowIndex < getRowCount();
+            //row count could be unknown, like in ResultSetDataModel
+            return isRowAvailable();
         }
 
         public E next()
@@ -185,18 +191,12 @@ public abstract class DataModel<E> imple
             //       Or the spec needs to specify that the iterator alters the selected row
explicitely
             if (hasNext())
             {
-                setRowIndex(nextRowIndex);
+                // TODO: Double-check if this cast is safe. It should be...
+                E data = (E) getRowData();
                 nextRowIndex++;
+                setRowIndex(nextRowIndex);
+                return data; 
                 
-                if (isRowAvailable())
-                {
-                    // TODO: Double-check if this cast is safe. It should be...
-                    return (E) getRowData();
-                }
-                else
-                {
-                    nextRowIndex--;
-                }
             }
             
             throw new NoSuchElementException("Couldn't find any element in DataModel at index
" + nextRowIndex);

Modified: myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/model/ResultSetDataModel.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/model/ResultSetDataModel.java?rev=1155050&r1=1155049&r2=1155050&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/model/ResultSetDataModel.java
(original)
+++ myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/model/ResultSetDataModel.java
Mon Aug  8 18:38:54 2011
@@ -269,14 +269,15 @@ public class ResultSetDataModel extends 
         @Override
         public boolean containsValue(Object value)
         {
-            for (String key : keySet())
+            //Iterate over entry set is better, because an entry
+            //key could have null value.
+            for (Map.Entry<String, Object> entry : entrySet())
             {
-                Object object = get(key);
-                if (object == null)
+                if (value != null && value.equals(entry.getValue()))
                 {
-                    return value == null;
+                    return true;
                 }
-                else if (object.equals(value))
+                else if (value == null && entry.getValue() == null)
                 {
                     return true;
                 }



Mime
View raw message