You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by de...@apache.org on 2017/09/17 12:29:59 UTC
[myfaces-trinidad] 01/07: Merge of trunk SVN revisions 1096803,
1096816 and 1096825 for TRINIDAD-2047
This is an automated email from the ASF dual-hosted git repository.
deki pushed a commit to branch 1.2.12.5.0-branch
in repository https://gitbox.apache.org/repos/asf/myfaces-trinidad.git
commit c6b85909563ffb7be5a2115bed83d844dc695a3f
Author: Andrew Robinson <ar...@apache.org>
AuthorDate: Thu Apr 28 21:41:19 2011 +0000
Merge of trunk SVN revisions 1096803, 1096816 and 1096825 for TRINIDAD-2047
---
.../trinidad/component/UIXTableTemplate.java | 41 +++++++++++++++++++--
.../trinidad/component/UIXTreeTemplate.java | 42 ++++++++++++++++++++--
.../myfaces/trinidad/component/UIXCollection.java | 19 +++++++---
3 files changed, 93 insertions(+), 9 deletions(-)
diff --git a/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTableTemplate.java b/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTableTemplate.java
index bcfe3e4..2b65681 100644
--- a/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTableTemplate.java
+++ b/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTableTemplate.java
@@ -55,6 +55,15 @@ import org.apache.myfaces.trinidad.model.SortCriterion;
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 extends UIXIteratorTemplate
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;
}
@@ -536,6 +554,25 @@ abstract public class UIXTableTemplate extends UIXIteratorTemplate
@Override
public Object getProperty(PropertyKey key)
{
+ 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.
+ return 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.
+ return super.getProperty(SELECTED_ROW_KEYS_KEY);
+ }
+
Object value = super.getProperty(key);
if (key == DISCLOSED_ROW_KEYS_KEY)
{
diff --git a/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTreeTemplate.java b/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTreeTemplate.java
index 8e497e1..7c28963 100644
--- a/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTreeTemplate.java
+++ b/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTreeTemplate.java
@@ -56,6 +56,16 @@ abstract public class UIXTreeTemplate extends UIXHierarchy
/**/ static public final PropertyKey DISCLOSED_ROW_KEYS_KEY = null;
/**/ static public final PropertyKey SELECTED_ROW_KEYS_KEY = null;
+/**/ static public final FacesBean.Type TYPE = new FacesBean.Type(org.apache.myfaces.trinidad.component.UIXHierarchy.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);
+
@Deprecated
public void setRowDisclosureListener(MethodBinding binding)
{
@@ -170,8 +180,17 @@ abstract public class UIXTreeTemplate extends UIXHierarchy
Object[] state = new Object[4];
state[0] = super.__getMyStampState();
state[1] = getFocusRowKey();
- state[2] = getSelectedRowKeys();
- state[3] = 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[2] = selectedRowKeys;
+ state[3] = disclosedRowKeys;
+
return state;
}
@@ -210,6 +229,25 @@ abstract public class UIXTreeTemplate extends UIXHierarchy
@Override
public Object getProperty(PropertyKey key)
{
+ 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.
+ return 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.
+ return super.getProperty(SELECTED_ROW_KEYS_KEY);
+ }
+
Object value = super.getProperty(key);
if (key == DISCLOSED_ROW_KEYS_KEY)
{
diff --git a/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java b/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java
index ee77b0a..6534721 100644
--- a/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java
+++ b/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java
@@ -770,6 +770,11 @@ public abstract class UIXCollection extends UIXComponentBase
/**
* 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()
{
@@ -1466,11 +1471,15 @@ public abstract class UIXCollection extends UIXComponentBase
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())
--
To stop receiving notification emails like this one, please contact
"commits@myfaces.apache.org" <co...@myfaces.apache.org>.