You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by aw...@apache.org on 2007/07/27 00:59:22 UTC
svn commit: r560026 -
/myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java
Author: awiner
Date: Thu Jul 26 15:59:21 2007
New Revision: 560026
URL: http://svn.apache.org/viewvc?view=rev&rev=560026
Log:
TRINIDAD-132: UIXCollection.invokeOnComponent() never flushes the model cache
- Flush the model cache the first time we call UIXCollection.invokeOnComponent() in any one request
Modified:
myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java
Modified: myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java?view=diff&rev=560026&r1=560025&r2=560026
==============================================================================
--- myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java (original)
+++ myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java Thu Jul 26 15:59:21 2007
@@ -981,6 +981,9 @@
String thisClientId = getClientId(context);
if (clientId.equals(thisClientId))
{
+ if (_getAndMarkFirstInvokeForRequest(context, clientId))
+ _flushCachedModel();
+
callback.invokeContextCallback(context, this);
return true;
}
@@ -990,6 +993,9 @@
if (clientId.startsWith(thisClientId) &&
(clientId.charAt(thisClientIdLength) == NamingContainer.SEPARATOR_CHAR))
{
+ if (_getAndMarkFirstInvokeForRequest(context, clientId))
+ _flushCachedModel();
+
String postId = clientId.substring(thisClientIdLength + 1);
int sepIndex = postId.indexOf(NamingContainer.SEPARATOR_CHAR);
// If there's no separator character afterwards, then this
@@ -1142,6 +1148,25 @@
iState._model = createCollectionModel(iState._model, value);
}
}
+
+ //
+ // Returns true if this is the first request to invokeOnComponent()
+ //
+ static private boolean _getAndMarkFirstInvokeForRequest(
+ FacesContext context, String clientId)
+ {
+ // See if the request contains a marker that we've hit this
+ // method already for this clientId
+ Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
+ String key = _INVOKE_KEY + clientId;
+ // Yep, we have, so return true
+ if (requestMap.containsKey(key))
+ return true;
+
+ // Stash TRUE for next time, and return false
+ requestMap.put(key, Boolean.TRUE);
+ return false;
+ }
/**
* Gets the internal state of this component.
@@ -1428,6 +1453,9 @@
// be Serializable:
private static final Object _NULL = new Object();
private static final Object[] _EMPTY_ARRAY = new Object[0];
+ private static final String _INVOKE_KEY =
+ UIXCollection.class.getName() + ".INVOKE";
+
private static final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(UIXCollection.class);
// An enum to throw into state-saving so that we get a nice