You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ar...@apache.org on 2011/04/26 19:12:12 UTC

svn commit: r1096808 - in /myfaces/trinidad/branches/trinidad-1.2.x: ./ trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTableTemplate.java trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java

Author: arobinson74
Date: Tue Apr 26 17:12:12 2011
New Revision: 1096808

URL: http://svn.apache.org/viewvc?rev=1096808&view=rev
Log:
TRINIDAD-2047 -- back out my previous change, added comments to the code to explain what it is actually doing and added a work-around to UIXTable to prevent the getCollectionModel() from being called during the saving of stamp state

Modified:
    myfaces/trinidad/branches/trinidad-1.2.x/   (props changed)
    myfaces/trinidad/branches/trinidad-1.2.x/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTableTemplate.java
    myfaces/trinidad/branches/trinidad-1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java

Propchange: myfaces/trinidad/branches/trinidad-1.2.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Apr 26 17:12:12 2011
@@ -8,4 +8,4 @@
 /myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree_3:984258-984269
 /myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree_4:984270-988607
 /myfaces/trinidad/branches/jwaldman_StyleMap:754977-770778
-/myfaces/trinidad/trunk:930425,932153,1002826,1031716,1076418
+/myfaces/trinidad/trunk:930425,932153,1002826,1031716,1076418,1096803

Modified: myfaces/trinidad/branches/trinidad-1.2.x/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTableTemplate.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-1.2.x/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTableTemplate.java?rev=1096808&r1=1096807&r2=1096808&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-1.2.x/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTableTemplate.java (original)
+++ myfaces/trinidad/branches/trinidad-1.2.x/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTableTemplate.java Tue Apr 26 17:12:12 2011
@@ -54,6 +54,15 @@ import org.apache.myfaces.trinidad.model
 abstract public class UIXTableTemplate extends UIXIteratorTemplate
   implements CollectionComponent
 {
+/**/  static public final FacesBean.Type TYPE = new FacesBean.Type(UIXIterator.TYPE);
+
+  // These are "fake" properties that allow the table to get the disclosed row keys and the
+  // selected row key without triggering the call to getCollectionModel from the
+  // RowKeyFacesBeanWrapper class. See the stamp state saving code for its usage.
+  static private final PropertyKey _DISCLOSED_ROW_KEYS_WITHOUT_MODEL_KEY =
+    TYPE.registerKey("disclosedRowKeysWithoutModel", RowKeySet.class);
+  static private final PropertyKey _SELECTED_ROW_KEYS_WITHOUT_MODEL_KEY =
+    TYPE.registerKey("selectedRowKeysWithoutModel", RowKeySet.class);
 
 
   /**
@@ -422,8 +431,17 @@ abstract public class UIXTableTemplate e
     state[1] = super.__getMyStampState();
     state[2] = Integer.valueOf(getFirst());
     state[3] = Boolean.valueOf(isShowAll());
-    state[4] = getSelectedRowKeys();
-    state[5] = getDisclosedRowKeys();
+
+    // Use "hidden" property keys to allow the row key sets to be retrieved without the
+    // RowKeyFacesBeanWrapper trying to resolve the collection model to be set into the row key
+    // set. This is needed to stop the unnecessary lookup of the collection model when it is not
+    // needed during stamp state saving of the table.
+    RowKeySet selectedRowKeys = (RowKeySet)getProperty(_SELECTED_ROW_KEYS_WITHOUT_MODEL_KEY);
+    RowKeySet disclosedRowKeys = (RowKeySet)getProperty(_DISCLOSED_ROW_KEYS_WITHOUT_MODEL_KEY);
+
+    state[4] = selectedRowKeys;
+    state[5] = disclosedRowKeys;
+
     return state;
   }
 
@@ -579,6 +597,24 @@ abstract public class UIXTableTemplate e
           }
         }
       }
+      else if (key == _DISCLOSED_ROW_KEYS_WITHOUT_MODEL_KEY)
+      {
+        // This case is only true if the table is trying to serialize the disclosed row keys to
+        // the stamp state of a parent UIXCollection. This work-around prevents EL evaluation to
+        // get the collection model during stamp state saving. This should be permissible as the
+        // state saving code does not need the collection model to be set in the row key set in
+        // order to save its state.
+        value = super.getProperty(DISCLOSED_ROW_KEYS_KEY);
+      }
+      else if (key == _SELECTED_ROW_KEYS_WITHOUT_MODEL_KEY)
+      {
+        // This case is only true if the table is trying to serialize the selected row keys to
+        // the stamp state of a parent UIXCollection. This work-around prevents EL evaluation to
+        // get the collection model during stamp state saving. This should be permissible as the
+        // state saving code does not need the collection model to be set in the row key set in
+        // order to save its state.
+        value = super.getProperty(SELECTED_ROW_KEYS_KEY);
+      }
 
       return value;
     }

Modified: myfaces/trinidad/branches/trinidad-1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java?rev=1096808&r1=1096807&r2=1096808&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java (original)
+++ myfaces/trinidad/branches/trinidad-1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java Tue Apr 26 17:12:12 2011
@@ -840,6 +840,11 @@ public abstract class UIXCollection exte
   /**
    * Gets the currencyObject to setup the rowData to use to build initial
    * stamp state.
+   * <p>
+   *   This allows the collection model to have an initial row key outside of the UIComponent.
+   *   Should the model be at a row that is not the first row, the component will restore the row
+   *   back to the initial row key instead of a null row key once stamping is done.
+   * </p>
    */
   private Object _getCurrencyKeyForInitialStampState()
   {
@@ -1810,11 +1815,15 @@ public abstract class UIXCollection exte
     FacesContext context = getFacesContext();
     Object currencyObj = getRowKey();
 
-    // TRINIDAD-2047: we do not need to save stamp state if there is no active stamp
-    if (currencyObj == null)
-    {
-      return;
-    }
+    // Note: even though the currencyObj may be null, we still need to save the state. The reason
+    // is that the code does not clear out the state when it is saved, instead, the un-stamped
+    // state is saved. Once the row key is set back to null, this un-stamped state is restored
+    // onto the children components. This restoration allows editable value holders, show detail
+    // items and nested UIXCollections to clear their state.
+    // For nested UIXCollections, this un-stamped state is required to set the nested collection's
+    // _state (internal state containing the stamp state) to null when not on a row key. Without
+    // that call, the nested UIXCollection components would end up sharing the same stamp state
+    // across parent rows.
 
     int position = 0;
     for(UIComponent stamp : getStamps())