You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by so...@apache.org on 2011/03/11 17:58:03 UTC

svn commit: r1080666 - /myfaces/trinidad/branches/trinidad-1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/RowKeySetAttributeChange.java

Author: sobryan
Date: Fri Mar 11 16:58:03 2011
New Revision: 1080666

URL: http://svn.apache.org/viewvc?rev=1080666&view=rev
Log:
TRINIDAD-2057 - Patch submitted by Gary and Blake.

Thanks guys!

Modified:
    myfaces/trinidad/branches/trinidad-1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/RowKeySetAttributeChange.java

Modified: myfaces/trinidad/branches/trinidad-1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/RowKeySetAttributeChange.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/RowKeySetAttributeChange.java?rev=1080666&r1=1080665&r2=1080666&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/RowKeySetAttributeChange.java (original)
+++ myfaces/trinidad/branches/trinidad-1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/RowKeySetAttributeChange.java Fri Mar 11 16:58:03 2011
@@ -58,14 +58,11 @@ public final class RowKeySetAttributeCha
       if (attributeValue instanceof RowKeySet)
       {
         ValueExpression expression = uiComponent.getValueExpression(attributeName);
-
-        Object oldValue;
+        final FacesContext context = FacesContext.getCurrentInstance();
         
         if (expression != null)
         {
           //use EL to get the oldValue and then determine whether we need to update in place
-          final FacesContext context = FacesContext.getCurrentInstance();
-                    
           context.getViewRoot().invokeOnComponent(
             context,
             _clientId,
@@ -73,19 +70,12 @@ public final class RowKeySetAttributeCha
         }
         else
         {
-          oldValue = attributeMap.get(attributeName);
-
-          if (oldValue instanceof RowKeySet)
-          {
-            _updateKeySet(_clientId, (RowKeySet)oldValue, (RowKeySet)attributeValue);
-            
-            // we updated in place, but we still need to set the attribute in order for partial
-            // state saving to work
-          }
-        }      
+          context.getViewRoot().invokeOnComponent(context, _clientId,
+                 new GetOldValueAndUpdate(attributeName, (RowKeySet)attributeValue));
+        
+        }       
       }
       
-      
       attributeMap.put(attributeName, attributeValue);
     }
   }
@@ -120,19 +110,41 @@ public final class RowKeySetAttributeCha
   {
     public GetOldValueAndUpdate(ValueExpression expression, RowKeySet newKeySet)
     {
+      _attributeName = null;
       _expression = expression;
       _newKeySet  = newKeySet;
     }
+    public GetOldValueAndUpdate(String attributeName, RowKeySet newKeySet)
+    {
+      _expression = null;
+      _attributeName = attributeName;
+      _newKeySet  = newKeySet;
+    }
+
     public void invokeContextCallback(FacesContext context,
                                       UIComponent target)
     {
-      // update the KeySet with the old and new values
-      RowKeySetAttributeChange._updateKeySet(null,
+      if (_expression != null)
+      {
+        // update the KeySet with the old and new values
+        RowKeySetAttributeChange._updateKeySet(null,
                                              (RowKeySet)_expression.getValue(context.getELContext()),
                                              _newKeySet);
+      }
+      else 
+      {
+        Map<String, Object> attributeMap = target.getAttributes();
+        RowKeySet oldKeySet = (RowKeySet) attributeMap.get(_attributeName);
+
+        // update the KeySet with the old and new values
+        RowKeySetAttributeChange._updateKeySet(null,
+                                             oldKeySet,
+                                             _newKeySet);
+      }
     }
     
     private final ValueExpression _expression;
+    private final String _attributeName;
     private final RowKeySet _newKeySet;
   }