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 2010/10/12 21:36:42 UTC
svn commit: r1021896 - in /myfaces/trinidad/trunk:
trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/
trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/html/
trinidad-api/src/main/java/org/apache/myface...
Author: arobinson74
Date: Tue Oct 12 19:36:41 2010
New Revision: 1021896
URL: http://svn.apache.org/viewvc?rev=1021896&view=rev
Log:
TRINIDAD-1919
Implement a component change manager that allows the collection components to suspend their changes during an invoke on component call or visit tree call
Added:
myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXDocumentTemplate.java (with props)
myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/html/
myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/html/HtmlBodyTemplate.java (with props)
myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/html/HtmlHeadTemplate.java (with props)
myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ComponentContextChange.java (with props)
myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ComponentContextManager.java (with props)
myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ComponentContextManagerImpl.java (with props)
myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/SuspendCallback.java (with props)
myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/SuspendedContextChanges.java (with props)
Modified:
myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java
myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RequestContext.java
myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/CoreRenderer.java
myfaces/trinidad/trunk/trinidad-api/src/test/java/org/apache/myfaces/trinidad/component/UIComponentTestCase.java
myfaces/trinidad/trunk/trinidad-api/src/test/java/org/apache/myfaces/trinidad/context/MockRequestContext.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java
myfaces/trinidad/trunk/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/renderkit/MRequestContext.java
myfaces/trinidad/trunk/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TableSelectOneRendererTest.java
Added: myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXDocumentTemplate.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXDocumentTemplate.java?rev=1021896&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXDocumentTemplate.java (added)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXDocumentTemplate.java Tue Oct 12 19:36:41 2010
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.trinidad.component;
+
+import javax.faces.FacesException;
+import javax.faces.component.ContextCallback;
+import javax.faces.component.visit.VisitCallback;
+import javax.faces.component.visit.VisitContext;
+import javax.faces.context.FacesContext;
+
+import org.apache.myfaces.trinidad.context.ComponentContextManager;
+import org.apache.myfaces.trinidad.context.RequestContext;
+import org.apache.myfaces.trinidad.context.SuspendedContextChanges;
+
+
+public abstract class UIXDocumentTemplate
+ extends UIXComponentBase
+{
+ @Override
+ public boolean visitTree(
+ VisitContext visitContext,
+ VisitCallback callback)
+ {
+ ComponentContextManager ctxMgr = RequestContext.getCurrentInstance()
+ .getComponentContextManager();
+ FacesContext facesContext = visitContext.getFacesContext();
+
+ // Suspend any current component context during a visit tree for re-entrant
+ // component tree processing
+ SuspendedContextChanges suspendedChanges = ctxMgr.suspend(facesContext);
+
+ try
+ {
+ return super.visitTree(visitContext, callback);
+ }
+ finally
+ {
+ ctxMgr.resume(facesContext, suspendedChanges);
+ }
+ }
+
+ @Override
+ public boolean invokeOnComponent(
+ FacesContext facesContext,
+ String clientId,
+ ContextCallback callback
+ ) throws FacesException
+ {
+ ComponentContextManager ctxMgr = RequestContext.getCurrentInstance()
+ .getComponentContextManager();
+
+ // Suspend any current component context during an invoke on component call for re-entrant
+ // component tree processing
+ SuspendedContextChanges suspendedChanges = ctxMgr.suspend(facesContext);
+
+ try
+ {
+ return super.invokeOnComponent(facesContext, clientId, callback);
+ }
+ finally
+ {
+ ctxMgr.resume(facesContext, suspendedChanges);
+ }
+ }
+}
Propchange: myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXDocumentTemplate.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/html/HtmlBodyTemplate.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/html/HtmlBodyTemplate.java?rev=1021896&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/html/HtmlBodyTemplate.java (added)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/html/HtmlBodyTemplate.java Tue Oct 12 19:36:41 2010
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.trinidad.component.html;
+
+import javax.faces.FacesException;
+import javax.faces.component.ContextCallback;
+import javax.faces.component.visit.VisitCallback;
+import javax.faces.component.visit.VisitContext;
+import javax.faces.context.FacesContext;
+
+import org.apache.myfaces.trinidad.component.UIXComponentBase;
+import org.apache.myfaces.trinidad.context.ComponentContextManager;
+import org.apache.myfaces.trinidad.context.RequestContext;
+import org.apache.myfaces.trinidad.context.SuspendedContextChanges;
+
+
+public abstract class HtmlBodyTemplate
+ extends UIXComponentBase
+{
+ @Override
+ public boolean visitTree(
+ VisitContext visitContext,
+ VisitCallback callback)
+ {
+ ComponentContextManager ctxMgr = RequestContext.getCurrentInstance()
+ .getComponentContextManager();
+ FacesContext facesContext = visitContext.getFacesContext();
+
+ // Suspend any current component context during a visit tree for re-entrant
+ // component tree processing
+ SuspendedContextChanges suspendedChanges = ctxMgr.suspend(facesContext);
+
+ try
+ {
+ return super.visitTree(visitContext, callback);
+ }
+ finally
+ {
+ ctxMgr.resume(facesContext, suspendedChanges);
+ }
+ }
+
+ @Override
+ public boolean invokeOnComponent(
+ FacesContext facesContext,
+ String clientId,
+ ContextCallback callback
+ ) throws FacesException
+ {
+ ComponentContextManager ctxMgr = RequestContext.getCurrentInstance()
+ .getComponentContextManager();
+
+ // Suspend any current component context during an invoke on component call for re-entrant
+ // component tree processing
+ SuspendedContextChanges suspendedChanges = ctxMgr.suspend(facesContext);
+
+ try
+ {
+ return super.invokeOnComponent(facesContext, clientId, callback);
+ }
+ finally
+ {
+ ctxMgr.resume(facesContext, suspendedChanges);
+ }
+ }
+}
\ No newline at end of file
Propchange: myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/html/HtmlBodyTemplate.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/html/HtmlHeadTemplate.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/html/HtmlHeadTemplate.java?rev=1021896&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/html/HtmlHeadTemplate.java (added)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/html/HtmlHeadTemplate.java Tue Oct 12 19:36:41 2010
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.trinidad.component.html;
+
+import javax.faces.FacesException;
+import javax.faces.component.ContextCallback;
+import javax.faces.component.visit.VisitCallback;
+import javax.faces.component.visit.VisitContext;
+import javax.faces.context.FacesContext;
+
+import org.apache.myfaces.trinidad.component.UIXComponentBase;
+import org.apache.myfaces.trinidad.context.ComponentContextManager;
+import org.apache.myfaces.trinidad.context.RequestContext;
+import org.apache.myfaces.trinidad.context.SuspendedContextChanges;
+
+
+public abstract class HtmlHeadTemplate
+ extends UIXComponentBase
+{
+ @Override
+ public boolean visitTree(
+ VisitContext visitContext,
+ VisitCallback callback)
+ {
+ ComponentContextManager ctxMgr = RequestContext.getCurrentInstance()
+ .getComponentContextManager();
+ FacesContext facesContext = visitContext.getFacesContext();
+
+ // Suspend any current component context during a visit tree for re-entrant
+ // component tree processing
+ SuspendedContextChanges suspendedChanges = ctxMgr.suspend(facesContext);
+
+ try
+ {
+ return super.visitTree(visitContext, callback);
+ }
+ finally
+ {
+ ctxMgr.resume(facesContext, suspendedChanges);
+ }
+ }
+
+ @Override
+ public boolean invokeOnComponent(
+ FacesContext facesContext,
+ String clientId,
+ ContextCallback callback
+ ) throws FacesException
+ {
+ ComponentContextManager ctxMgr = RequestContext.getCurrentInstance()
+ .getComponentContextManager();
+
+ // Suspend any current component context during an invoke on component call for re-entrant
+ // component tree processing
+ SuspendedContextChanges suspendedChanges = ctxMgr.suspend(facesContext);
+
+ try
+ {
+ return super.invokeOnComponent(facesContext, clientId, callback);
+ }
+ finally
+ {
+ ctxMgr.resume(facesContext, suspendedChanges);
+ }
+ }
+}
\ No newline at end of file
Propchange: myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/html/HtmlHeadTemplate.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java?rev=1021896&r1=1021895&r2=1021896&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java Tue Oct 12 19:36:41 2010
@@ -23,7 +23,6 @@ import java.io.ObjectInputStream;
import java.io.Serializable;
import java.util.AbstractMap;
-import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -33,6 +32,10 @@ import javax.faces.FacesException;
import javax.faces.component.ContextCallback;
import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
+import javax.faces.component.visit.VisitCallback;
+import javax.faces.component.visit.VisitContext;
+import javax.faces.component.visit.VisitContextWrapper;
+import javax.faces.component.visit.VisitResult;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
@@ -41,11 +44,9 @@ import javax.faces.render.Renderer;
import org.apache.myfaces.trinidad.bean.FacesBean;
import org.apache.myfaces.trinidad.bean.PropertyKey;
-import javax.faces.component.visit.VisitCallback;
-import javax.faces.component.visit.VisitContext;
-import javax.faces.component.visit.VisitContextWrapper;
-import javax.faces.component.visit.VisitHint;
-import javax.faces.component.visit.VisitResult;
+import org.apache.myfaces.trinidad.context.ComponentContextChange;
+import org.apache.myfaces.trinidad.context.ComponentContextManager;
+import org.apache.myfaces.trinidad.context.RequestContext;
import org.apache.myfaces.trinidad.event.SelectionEvent;
import org.apache.myfaces.trinidad.logging.TrinidadLogger;
import org.apache.myfaces.trinidad.model.CollectionModel;
@@ -337,27 +338,27 @@ public abstract class UIXCollection exte
}
/**
- * Check for an available row by row key.
+ * Check for an available row by row key.
* @param rowKey the row key for the row to check.
* @return true if a value exists; false otherwise.
*/
public final boolean isRowAvailable(Object rowKey)
{
- return getCollectionModel().isRowAvailable(rowKey);
+ return getCollectionModel().isRowAvailable(rowKey);
}
-
+
/**
- * Get row data by row key.
+ * Get row data by row key.
* @param rowKey the row key for the row to get data.
* @return row data
*/
public final Object getRowData(Object rowKey)
{
- return getCollectionModel().getRowData(rowKey);
+ return getCollectionModel().getRowData(rowKey);
}
-
+
/**
- * Check if a range of rows is available starting from the current position
+ * Check if a range of rows is available starting from the current position
* @param rowCount number of rows to check
* @return true if all rows in range are available
*/
@@ -365,21 +366,21 @@ public abstract class UIXCollection exte
{
return getCollectionModel().areRowsAvailable(rowCount);
}
-
+
/**
- * Check if a range of rows is available from a starting index without
+ * Check if a range of rows is available from a starting index without
* requiring the client to iterate over the rows
* @param startIndex the starting index for the range
* @param rowCount number of rows to check
* @return true if all rows in range are available
*/
- public final boolean areRowsAvailable(int startIndex, int rowCount)
+ public final boolean areRowsAvailable(int startIndex, int rowCount)
{
return getCollectionModel().areRowsAvailable(startIndex, rowCount);
}
-
+
/**
- * Check if a range of rows is available from a starting row key without
+ * Check if a range of rows is available from a starting row key without
* requiring the client to iterate over the rows
* @param startRowKey the starting row key for the range
* @param rowCount number of rows to check
@@ -389,8 +390,8 @@ public abstract class UIXCollection exte
{
return getCollectionModel().areRowsAvailable(startRowKey, rowCount);
}
-
-
+
+
/**
* Gets the total number of rows in this table.
@@ -669,9 +670,6 @@ public abstract class UIXCollection exte
return key;
}
-
-
-
/**
* This is a safe way of getting currency keys and not accidentally forcing
* the model to execute. When rendered="false" we should never execute the model.
@@ -772,6 +770,16 @@ public abstract class UIXCollection exte
" and currencyKey:"+getRowKey());
}
+ ComponentContextManager compCtxMgr =
+ RequestContext.getCurrentInstance().getComponentContextManager();
+ ComponentContextChange change = compCtxMgr.peekChange();
+ if (change instanceof CollectionComponentChange &&
+ ((CollectionComponentChange)change)._component == this)
+ {
+ // Remove the component context change if one was added
+ compCtxMgr.popChange();
+ }
+
InternalState iState = _getInternalState(true);
if (rowData == null)
{
@@ -805,6 +813,10 @@ public abstract class UIXCollection exte
Map<String, Object> varStatusMap = createVarStatusMap();
iState._prevVarStatus = _setELVar(iState._varStatus, varStatusMap);
}
+
+ // If there is a current row, push a component change so that we may clear the
+ // var and var status should a visit tree occur
+ compCtxMgr.pushChange(new CollectionComponentChange(this));
}
_restoreStampState();
@@ -813,9 +825,10 @@ public abstract class UIXCollection exte
// proper stamped IDs. This mirrors the behavior in UIData and follows the JSF specification
// on when client IDs are allowed to be cached and when they must be reset
List<UIComponent> stamps = getStamps();
-
+
for (UIComponent stamp : stamps)
UIXComponent.clearCachedClientIds(stamp);
+
}
/**
@@ -1101,7 +1114,7 @@ public abstract class UIXCollection exte
}
pushComponentToEL(context, null);
-
+
try
{
callback.invokeContextCallback(context, this);
@@ -1110,7 +1123,7 @@ public abstract class UIXCollection exte
{
popComponentFromEL(context);
}
-
+
invokedComponent = true;
}
else
@@ -1120,16 +1133,16 @@ public abstract class UIXCollection exte
int thisClientIdLength = thisClientId.length();
if (clientId.startsWith(thisClientId) &&
(clientId.charAt(thisClientIdLength) == NamingContainer.SEPARATOR_CHAR))
- {
+ {
if (!_getAndMarkFirstInvokeForRequest(context, thisClientId))
{
// Call _init() since _flushCachedModel() assumes that
// selectedRowKeys and disclosedRowKeys are initialized to be non-null
_init();
-
+
_flushCachedModel();
}
-
+
String postId = clientId.substring(thisClientIdLength + 1);
int sepIndex = postId.indexOf(NamingContainer.SEPARATOR_CHAR);
// If there's no separator character afterwards, then this
@@ -1140,7 +1153,7 @@ public abstract class UIXCollection exte
{
String currencyString = postId.substring(0, sepIndex);
Object rowKey = getClientRowKeyManager().getRowKey(context, this, currencyString);
-
+
// A non-null rowKey here means we are on a row and we should set currency, otherwise
// the client id is for a non-stamped child component in the table/column header/footer.
if (rowKey != null)
@@ -1174,7 +1187,7 @@ public abstract class UIXCollection exte
{
tearDownVisitingContext(context);
}
-
+
return invokedComponent;
}
@@ -1199,13 +1212,13 @@ public abstract class UIXCollection exte
{
return defaultVisitChildren(visitContext, callback);
}
-
+
protected final boolean defaultVisitChildren(
VisitContext visitContext,
VisitCallback callback)
{
boolean doneVisiting;
-
+
// Clear out the row index if one is set so that
// we start from a clean slate.
int oldRowIndex = getRowIndex();
@@ -1215,11 +1228,11 @@ public abstract class UIXCollection exte
{
// visit the unstamped children
doneVisiting = visitUnstampedFacets(visitContext, callback);
-
+
if (!doneVisiting)
{
doneVisiting = _visitStampedColumnFacets(visitContext, callback);
-
+
// visit the stamped children
if (!doneVisiting)
{
@@ -1230,12 +1243,12 @@ public abstract class UIXCollection exte
finally
{
// restore the original rowIndex
- setRowIndex(oldRowIndex);
+ setRowIndex(oldRowIndex);
}
-
- return doneVisiting;
+
+ return doneVisiting;
}
-
+
/**
* Hook method for subclasses to override to change the behavior
* of how unstamped facets of the UIXCollection are visited. The
@@ -1260,7 +1273,7 @@ public abstract class UIXCollection exte
return false;
}
-
+
/**
* VistiContext that visits the facets of the UIXColumn children, including
@@ -1272,13 +1285,13 @@ public abstract class UIXCollection exte
{
_wrapped = wrappedContext;
}
-
+
@Override
public VisitContext getWrapped()
{
return _wrapped;
}
-
+
@Override
public VisitResult invokeVisitCallback(UIComponent component, VisitCallback callback)
{
@@ -1292,7 +1305,7 @@ public abstract class UIXCollection exte
if (UIXComponent.visitTree(getWrapped(), facetChild, callback))
return VisitResult.COMPLETE;
}
-
+
// visit the indexed children, recursively looking for more columns
for (UIComponent child : component.getChildren())
{
@@ -1301,12 +1314,12 @@ public abstract class UIXCollection exte
}
}
}
-
+
// at this point, we either have already manually processed the UIXColumn's children, or
// the component wasn't a UIXColumn and shouldn't be processed
return VisitResult.REJECT;
}
-
+
private final VisitContext _wrapped;
}
@@ -1341,7 +1354,7 @@ public abstract class UIXCollection exte
return VisitResult.COMPLETE;
}
}
-
+
return VisitResult.REJECT;
}
else
@@ -1352,24 +1365,24 @@ public abstract class UIXCollection exte
return VisitResult.REJECT;
}
}
-
+
private final VisitContext _wrapped;
}
-
+
/**
* Implementation used to visit each stamped row
*/
private boolean _visitStampedColumnFacets(
VisitContext visitContext,
VisitCallback callback)
- {
+ {
// visit the facets of the stamped columns
List<UIComponent> stamps = getStamps();
-
+
if (!stamps.isEmpty())
{
VisitContext columnVisitingContext = new ColumnFacetsOnlyVisitContext(visitContext);
-
+
for (UIComponent stamp : stamps)
{
if (UIXComponent.visitTree(columnVisitingContext, stamp, callback))
@@ -1378,7 +1391,7 @@ public abstract class UIXCollection exte
}
}
}
-
+
return false;
}
@@ -1448,7 +1461,7 @@ public abstract class UIXCollection exte
protected abstract CollectionModel createCollectionModel(
CollectionModel current,
Object value);
-
+
/**
* Hook called with the result of <code>createCollectionModel</code>.
* Subclasses can use this method to perform initialization after the CollectionModel
@@ -1462,7 +1475,7 @@ public abstract class UIXCollection exte
{
// do nothing
}
-
+
/**
* Gets the value that must be converted into a CollectionModel
@@ -1505,15 +1518,15 @@ public abstract class UIXCollection exte
}
};
}
-
-
+
+
//
// LocalRowKeyIndex implementation
//
/**
* Given a row index, check if a row is locally available
- * @param rowIndex index of row to check
+ * @param rowIndex index of row to check
* @return true if row is locally available
*/
public boolean isRowLocallyAvailable(int rowIndex)
@@ -1523,7 +1536,7 @@ public abstract class UIXCollection exte
/**
* Given a row key, check if a row is locally available
- * @param rowKey row key for the row to check
+ * @param rowKey row key for the row to check
* @return true if row is locally available
*/
public boolean isRowLocallyAvailable(Object rowKey)
@@ -1543,7 +1556,7 @@ public abstract class UIXCollection exte
/**
* Check if a range of rows is locally available starting from a row index
- * @param startIndex staring index for the range
+ * @param startIndex staring index for the range
* @param rowCount number of rows in the range
* @return true if range of rows is locally available
*/
@@ -1554,7 +1567,7 @@ public abstract class UIXCollection exte
/**
* Check if a range of rows is locally available starting from a row key
- * @param startRowKey staring row key for the range
+ * @param startRowKey staring row key for the range
* @param rowCount number of rows in the range
* @return true if range of rows is locally available
*/
@@ -1562,9 +1575,9 @@ public abstract class UIXCollection exte
{
return getCollectionModel().areRowsLocallyAvailable(startRowKey, rowCount);
}
-
+
/**
- * Convenient API to return a row count estimate. This method can be optimized
+ * Convenient API to return a row count estimate. This method can be optimized
* to avoid a data fetch which may be required to return an exact row count
* @return estimated row count
*/
@@ -1575,14 +1588,14 @@ public abstract class UIXCollection exte
/**
- * Helper API to determine if the row count returned from {@link #getEstimatedRowCount}
+ * Helper API to determine if the row count returned from {@link #getEstimatedRowCount}
* is EXACT, or an ESTIMATE
*/
public LocalRowKeyIndex.Confidence getEstimatedRowCountConfidence()
{
return getCollectionModel().getEstimatedRowCountConfidence();
}
-
+
/**
* clear all rows from the local cache
*/
@@ -1590,7 +1603,7 @@ public abstract class UIXCollection exte
{
getCollectionModel().clearLocalCache();
}
-
+
/**
* Clear the requested range of rows from the local cache
* @param startingIndex starting row index for the range to clear
@@ -1600,7 +1613,7 @@ public abstract class UIXCollection exte
{
getCollectionModel().clearCachedRows(startingIndex, rowsToClear);
}
-
+
/**
* Clear the requested range of rows from the local cache
* @param startingRowKey starting row key for the range to clear
@@ -1610,7 +1623,7 @@ public abstract class UIXCollection exte
{
getCollectionModel().clearCachedRows(startingRowKey, rowsToClear);
}
-
+
/**
* Clear a row from the local cache by row index
* @param index row index for the row to clear from the cache
@@ -1619,16 +1632,16 @@ public abstract class UIXCollection exte
{
getCollectionModel().clearCachedRow(index);
}
-
+
/**
* Clear a row from the local cache by row key
* @param rowKey row key for the row to clear from the cache
*/
public void clearCachedRow(Object rowKey)
{
- getCollectionModel().clearCachedRow(rowKey);
+ getCollectionModel().clearCachedRow(rowKey);
}
-
+
/**
* Indicates the caching strategy supported by the model
* @see LocalRowKeyIndex.LocalCachingStrategy
@@ -1638,7 +1651,7 @@ public abstract class UIXCollection exte
{
return getCollectionModel().getCachingStrategy();
}
-
+
/**
* override this method to place initialization code that must run
@@ -1915,11 +1928,11 @@ public abstract class UIXCollection exte
if (key != null)
{
currencyCache.put(newRowKey, key);
- }
+ }
return key != null;
}
-
+
private static String _createToken(ValueMap<Object,String> currencyCache)
{
@@ -1974,6 +1987,63 @@ public abstract class UIXCollection exte
private static final long serialVersionUID = 1L;
}
+ /**
+ * Class to be able to suspend the context of the collection.
+ * <p>Current implementation removes the var and varStatus from the request while the
+ * collection is suspended.</p>
+ */
+ private static class CollectionComponentChange
+ extends ComponentContextChange
+ {
+ private CollectionComponentChange(
+ UIXCollection component)
+ {
+ this._component = component;
+ }
+
+ public void suspend(
+ FacesContext facesContext)
+ {
+ InternalState iState = _component._getInternalState(false);
+
+ if (iState != null)
+ {
+ if (iState._var != null)
+ {
+ _var = _component._setELVar(iState._var, _NULL);
+ }
+ if (iState._varStatus != null)
+ {
+ _varStatus = _component._setELVar(iState._varStatus, _NULL);
+ }
+ }
+ }
+
+ public void resume(
+ FacesContext facesContext)
+ {
+ InternalState iState = _component._getInternalState(false);
+
+ if (iState != null)
+ {
+ if (iState._var != null)
+ {
+ _component._setELVar(iState._var, _var);
+ _var = null;
+ }
+ if (iState._varStatus != null)
+ {
+ _varStatus = _component._setELVar(iState._varStatus, _varStatus);
+ _varStatus = null;
+ }
+ }
+ }
+
+ private final UIXCollection _component;
+ private Object _var;
+ private Object _varStatus;
+ }
+
// do not assign a non-null value. values should be assigned lazily. this is
// because this value is preserved by stampStateSaving, when table-within-table
// is used. And if a non-null value is used, then all nested tables will
Added: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ComponentContextChange.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ComponentContextChange.java?rev=1021896&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ComponentContextChange.java (added)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ComponentContextChange.java Tue Oct 12 19:36:41 2010
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.trinidad.context;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * Class that represents a change that is tied to a component in the component tree.
+ * This class is used by {@link ComponentContextManager} to be able to suspend and resume
+ * the context of a component during an invoke on component or visit tree call.
+ */
+public abstract class ComponentContextChange
+{
+ /**
+ * Suspends any changes that the component has made so that an invoke on component or
+ * visit tree call may be made without the context of the component interfering.
+ *
+ * @param facesContext The faces context
+ */
+ public abstract void suspend(FacesContext facesContext);
+
+ /**
+ * Resumes the suspended context of a component.
+ *
+ * @param facesContext The faces context
+ */
+ public abstract void resume(FacesContext facesContext);
+}
Propchange: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ComponentContextChange.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ComponentContextManager.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ComponentContextManager.java?rev=1021896&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ComponentContextManager.java (added)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ComponentContextManager.java Tue Oct 12 19:36:41 2010
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.trinidad.context;
+
+import java.util.Iterator;
+
+import javax.faces.context.FacesContext;
+
+
+/**
+ * Interface that controls access to the stack of component context changes. This class
+ * allows components to push changes onto a stack that must be rolled back in order to perform
+ * an {@link javax.faces.component.UIComponent#invokeOnComponent} or
+ * {@link javax.faces.component.UIComponent#visitTree} call in the proper context.
+ * <p>This functionality allows changes that only should apply when a component is currently
+ * processing its lifecycle to be temporarily suspended. For example, a component that alters
+ * the EL context should undo and changes when the component is not processing. An example of
+ * this is the Trinidad table that injects "var" and "varStatus" variables into the EL context
+ * while the table is iterating. By saving off these variables and restoring them, the EL will
+ * be correct should code perform an invoke on component or visit tree call, reentering the
+ * component tree from the view root.</p>
+ */
+public abstract class ComponentContextManager
+{
+ /**
+ * Push a change onto the stack.
+ *
+ * @param change The change to push
+ */
+ public abstract void pushChange(ComponentContextChange change);
+
+ /**
+ * Remove the latest change from the stack.
+ *
+ * @return the change that has been removed from the stack
+ * @throws IllegalStateException if an attempt is made to pop an empty stack
+ */
+ public abstract ComponentContextChange popChange()
+ throws IllegalStateException;
+
+ /**
+ * Get the latest change on the stack without removing it.
+ *
+ * @return the latest change or null if none
+ */
+ public abstract ComponentContextChange peekChange();
+
+ /**
+ * Suspend the entire stack of context changes. Used by the document to clear all changes
+ * during an invoke on component or visit tree call.
+ *
+ * @param facesContext The faces context
+ * @return an object to use to pass back to the {@link #resume} method to resume the suspend
+ * changes at a later time
+ */
+ public abstract SuspendedContextChanges suspend(FacesContext facesContext);
+
+ /**
+ * Suspend the changes on the stack to an arbitrary point. This method is useful should a
+ * component need to back out changes only to a certain point. For example, a compound
+ * component may need to back out any changes to be able to evaluate EL in the context
+ * of the defining page.
+ *
+ * @param facesContext the faces context
+ * @param callback a callback interface used to determine how far back to suspend.
+ * @return an object to use to pass back to the {@link #resume} method to resume the suspend
+ * changes at a later time
+ */
+ public abstract SuspendedContextChanges partialSuspend(
+ FacesContext facesContext,
+ SuspendCallback callback);
+
+ /**
+ * Resume a set of suspended changes.
+ *
+ * @param facesContext the faces context
+ * @param suspendedChanges a set of changes that have been previously suspended
+ * @return Iterator of changes that were resumed
+ * during the call (iterates in the earliest to most recent order).
+ */
+ public abstract Iterator<ComponentContextChange> resume(
+ FacesContext facesContext,
+ SuspendedContextChanges suspendedChanges);
+}
Propchange: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ComponentContextManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ComponentContextManagerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ComponentContextManagerImpl.java?rev=1021896&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ComponentContextManagerImpl.java (added)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ComponentContextManagerImpl.java Tue Oct 12 19:36:41 2010
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.trinidad.context;
+
+import java.util.ArrayDeque;
+import java.util.Collections;
+import java.util.Deque;
+import java.util.Iterator;
+import java.util.Queue;
+
+import javax.faces.context.FacesContext;
+
+
+/**
+ * Default, internal, implementation of the {@link ComponentContextManager} for use from the
+ * {@link RequestContext} class.
+ */
+final class ComponentContextManagerImpl
+ extends ComponentContextManager
+{
+ public void pushChange(ComponentContextChange change)
+ {
+ if (_stack == null)
+ {
+ _stack = Collections.asLifoQueue(new ArrayDeque<ComponentContextChange>());
+ }
+
+ _stack.offer(change);
+ }
+
+ public ComponentContextChange popChange()
+ throws IllegalStateException
+ {
+ if (_stack == null)
+ {
+ throw new IllegalStateException("No changes to pop");
+ }
+
+ ComponentContextChange change = _stack.poll();
+ if (_stack.isEmpty())
+ {
+ _stack = null;
+ }
+
+ return change;
+ }
+
+ public ComponentContextChange peekChange()
+ {
+ return _stack == null ? null : _stack.peek();
+ }
+
+ public SuspendedContextChanges suspend(FacesContext facesContext)
+ {
+ if (_stack == null)
+ {
+ return new SuspendedContextChangesImpl(new ArrayDeque<ComponentContextChange>(0));
+ }
+
+ ArrayDeque<ComponentContextChange> q = new ArrayDeque<ComponentContextChange>(_stack.size());
+ for (ComponentContextChange change : _stack)
+ {
+ change.suspend(facesContext);
+ q.offer(change);
+ }
+
+ _stack = null;
+
+ return new SuspendedContextChangesImpl(q);
+ }
+
+ public SuspendedContextChanges partialSuspend(
+ FacesContext facesContext,
+ SuspendCallback callback)
+ {
+ if (_stack == null)
+ {
+ return new SuspendedContextChangesImpl(new ArrayDeque<ComponentContextChange>(0));
+ }
+
+ ArrayDeque<ComponentContextChange> q = new ArrayDeque<ComponentContextChange>(_stack.size());
+ for (Iterator<ComponentContextChange> iter = _stack.iterator();
+ iter.hasNext(); )
+ {
+ ComponentContextChange change = iter.next();
+ SuspendCallback.SuspendResult result = callback.getSuspendResult(change);
+
+ if (result == SuspendCallback.SuspendResult.STOP)
+ {
+ break;
+ }
+
+ iter.remove();
+ change.suspend(facesContext);
+ q.offer(change);
+
+ if (result == SuspendCallback.SuspendResult.STOP_AFTER_CURRENT)
+ {
+ break;
+ }
+ }
+
+ if (_stack.isEmpty())
+ {
+ _stack = null;
+ }
+
+ return new SuspendedContextChangesImpl(q);
+ }
+
+ public Iterator<ComponentContextChange> resume(
+ FacesContext facesContext,
+ SuspendedContextChanges suspendedChanges)
+ {
+ assert suspendedChanges instanceof SuspendedContextChangesImpl :
+ "Invalid suspend changes";
+
+ SuspendedContextChangesImpl suspendedChangesImpl =
+ (SuspendedContextChangesImpl)suspendedChanges;
+
+ if (_stack == null)
+ {
+ _stack = Collections.asLifoQueue(new ArrayDeque<ComponentContextChange>());
+ }
+
+ for (Iterator<ComponentContextChange> iter =
+ suspendedChangesImpl._suspendedStack.descendingIterator();
+ iter.hasNext(); )
+ {
+ ComponentContextChange change = iter.next();
+ change.resume(facesContext);
+ _stack.offer(change);
+ }
+
+ return suspendedChangesImpl._suspendedStack.descendingIterator();
+ }
+
+ private static class SuspendedContextChangesImpl
+ extends SuspendedContextChanges
+ {
+ SuspendedContextChangesImpl(
+ Deque<ComponentContextChange> suspendedStack)
+ {
+ _suspendedStack = suspendedStack;
+ }
+
+ private Deque<ComponentContextChange> _suspendedStack;
+ }
+
+ private Queue<ComponentContextChange> _stack;
+}
\ No newline at end of file
Propchange: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ComponentContextManagerImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RequestContext.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RequestContext.java?rev=1021896&r1=1021895&r2=1021896&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RequestContext.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RequestContext.java Tue Oct 12 19:36:41 2010
@@ -34,14 +34,13 @@ import java.util.concurrent.ConcurrentMa
import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
+import javax.faces.component.visit.VisitContext;
+import javax.faces.component.visit.VisitHint;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseId;
import org.apache.myfaces.trinidad.change.ChangeManager;
-import javax.faces.component.visit.VisitContext;
-import javax.faces.component.visit.VisitHint;
-
import org.apache.myfaces.trinidad.component.visit.VisitTreeUtils;
import org.apache.myfaces.trinidad.config.RegionManager;
import org.apache.myfaces.trinidad.event.WindowLifecycleListener;
@@ -152,14 +151,14 @@ abstract public class RequestContext
public Map<String, Object> getWindowMap()
{
WindowManager wm = getWindowManager();
-
+
ExternalContext extContext = FacesContext.getCurrentInstance().getExternalContext();
-
+
Window window = wm.getCurrentWindow(extContext);
if (window != null)
{
-
+
return window.getWindowMap();
}
else
@@ -545,7 +544,7 @@ abstract public class RequestContext
* @param ids the client ids of the components to visit. If null,
* all components will be visited.
* @param hints the VisitHints to apply to the visit
- * @param phaseId. ignored.
+ * @param phaseId. ignored.
* @return a VisitContext instance that is initialized with the
* specified ids and hints.
*@deprecated use org.apache.component.visit.VisitTreeUtils#createVisitContext(FacesContext, Collection<String>, Set<VisitHint>)
@@ -632,26 +631,26 @@ abstract public class RequestContext
if (windowManager == null)
{
FacesContext context = FacesContext.getCurrentInstance();
-
+
// just in case we're called before the real JSF lifecycle starts
if (context != null)
{
// check if we have cached it per session
ExternalContext extContext = context.getExternalContext();
-
+
// create a new instance using the WindowManagerFactory
ConcurrentMap<String, Object> concurrentAppMap = getApplicationScopedConcurrentMap();
-
+
WindowManagerFactory windowManagerFactory = (WindowManagerFactory)concurrentAppMap.get(
_WINDOW_MANAGER_FACTORY_CLASS_NAME);
-
+
if (windowManagerFactory == null)
{
// we haven't registered a WindowManagerFactory yet, so use the services api to see
// if a factory has been registered
List<WindowManagerFactory> windowManagerFactories =
ClassLoaderUtils.getServices(_WINDOW_MANAGER_FACTORY_CLASS_NAME);
-
+
if (windowManagerFactories.isEmpty())
{
// no factory registered so use the factory that returns dummy stub WindowManagers
@@ -662,21 +661,21 @@ abstract public class RequestContext
// only one WindowManager is allowed, use it
windowManagerFactory = windowManagerFactories.get(0);
}
-
+
// save the WindowManagerFactory to the application if it hasn't already been saved
// if it has been saved, use the previously registered WindowManagerFactory
WindowManagerFactory oldWindowManagerFactory = (WindowManagerFactory)
concurrentAppMap.putIfAbsent(_WINDOW_MANAGER_FACTORY_CLASS_NAME,
windowManagerFactory);
-
+
if (oldWindowManagerFactory != null)
windowManagerFactory = oldWindowManagerFactory;
} // create WindowManagerFactory
-
+
// get the WindowManager from the factory. The factory will create a new instance
// for this session if necessary
windowManager = windowManagerFactory.getWindowManager(extContext);
-
+
// remember for the next call on this thread
_windowManager = windowManager;
}
@@ -686,6 +685,21 @@ abstract public class RequestContext
}
/**
+ * Get the component context manager.
+ * @return The manager of component context changes to be used to suspend and resume
+ * component specific context changes.
+ */
+ public ComponentContextManager getComponentContextManager()
+ {
+ if (_componentContextManager == null)
+ {
+ _componentContextManager = new ComponentContextManagerImpl();
+ }
+
+ return _componentContextManager;
+ }
+
+ /**
* Releases the RequestContext object. This method must only
* be called by the code that created the RequestContext.
* @exception IllegalStateException if no RequestContext is attached
@@ -822,6 +836,8 @@ abstract public class RequestContext
static private final TrinidadLogger _LOG =
TrinidadLogger.createTrinidadLogger(RequestContext.class);
+ private ComponentContextManager _componentContextManager;
+
// window manager for this request
private WindowManager _windowManager;
}
Added: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/SuspendCallback.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/SuspendCallback.java?rev=1021896&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/SuspendCallback.java (added)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/SuspendCallback.java Tue Oct 12 19:36:41 2010
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.trinidad.context;
+
+/**
+ * Class to use with {@link ComponentContextManager#partialSuspend} to control how far
+ * into the context change stack to suspend to. This is useful for components that need to
+ * suspend to a certain point in the change stack, but not the entire stack.
+ */
+public abstract class SuspendCallback
+{
+ /**
+ * Return value for the {@link #getSuspendResult(ComponentContextChange)} function to specify
+ * when to stop suspending the context change stack.
+ */
+ public enum SuspendResult
+ {
+ /**
+ * Stop checking changes, stop without suspending the current change.
+ */
+ STOP,
+
+ /**
+ * Stop checking changes, stop after suspending the current change.
+ */
+ STOP_AFTER_CURRENT,
+
+ /**
+ * The desired change has not yet been found, keep suspending.
+ */
+ CONTINUE
+ }
+
+ /**
+ * Determine how suspension should behave with regards to partial suspension.
+ *
+ * @param change The change to consider suspending
+ * @return enumeration specifying how far to suspend to
+ */
+ public abstract SuspendResult getSuspendResult(
+ ComponentContextChange change);
+}
Propchange: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/SuspendCallback.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/SuspendedContextChanges.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/SuspendedContextChanges.java?rev=1021896&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/SuspendedContextChanges.java (added)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/SuspendedContextChanges.java Tue Oct 12 19:36:41 2010
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.trinidad.context;
+
+/**
+ * Marker class used to hold suspend context changes.
+ * @see ComponentContextManager#suspend
+ * @see ComponentContextManager#partialSuspend
+ * @see ComponentContextManager#resume
+ */
+public abstract class SuspendedContextChanges
+{
+}
Propchange: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/SuspendedContextChanges.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/CoreRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/CoreRenderer.java?rev=1021896&r1=1021895&r2=1021896&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/CoreRenderer.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/CoreRenderer.java Tue Oct 12 19:36:41 2010
@@ -484,16 +484,43 @@ public class CoreRenderer extends Render
"NO_RENDERINGCONTEXT"));
FacesBean bean = getFacesBean(component);
- if (getRendersChildren())
+ RuntimeException re = null;
+ try
{
- beforeEncode(context, rc, component, bean);
- encodeAll(context, rc, component, bean);
+ if (getRendersChildren())
+ {
+ beforeEncode(context, rc, component, bean);
+ encodeAll(context, rc, component, bean);
+ }
+ else
+ {
+ encodeEnd(context, rc, component, bean);
+ }
}
- else
+ catch (RuntimeException ex)
+ {
+ re = ex;
+ }
+ finally
{
- encodeEnd(context, rc, component, bean);
+ try
+ {
+ afterEncode(context, rc, component, bean);
+ }
+ catch (RuntimeException ex)
+ {
+ if (re == null)
+ {
+ throw ex;
+ }
+ _LOG.warning(ex);
+ }
+
+ if (re != null)
+ {
+ throw re;
+ }
}
- afterEncode(context, rc, component, bean);
}
/**
Modified: myfaces/trinidad/trunk/trinidad-api/src/test/java/org/apache/myfaces/trinidad/component/UIComponentTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/test/java/org/apache/myfaces/trinidad/component/UIComponentTestCase.java?rev=1021896&r1=1021895&r2=1021896&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/test/java/org/apache/myfaces/trinidad/component/UIComponentTestCase.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/test/java/org/apache/myfaces/trinidad/component/UIComponentTestCase.java Tue Oct 12 19:36:41 2010
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -22,6 +22,7 @@ import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
+
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
@@ -29,16 +30,16 @@ import java.lang.reflect.Method;
import java.util.Collections;
import java.util.Map;
+
import javax.faces.component.EditableValueHolder;
import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
import javax.faces.component.ValueHolder;
import javax.faces.context.FacesContext;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.ValueChangeListener;
-
import javax.faces.convert.Converter;
import javax.faces.el.ValueBinding;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.ValueChangeListener;
import javax.faces.render.RenderKit;
import javax.faces.render.RenderKitFactory;
import javax.faces.render.Renderer;
@@ -47,12 +48,14 @@ import javax.faces.validator.Validator;
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.apache.myfaces.trinidad.component.UIXComponent;
+import org.apache.myfaces.trinidad.context.MockRequestContext;
import org.apache.myfaces.trinidad.event.AttributeChangeEvent;
import org.apache.myfaces.trinidadbuild.test.FacesTestCase;
+
import org.jmock.Mock;
import org.jmock.core.Constraint;
+
/**
* Base class for JavaServer Faces UIComponent unit tests.
*
@@ -69,19 +72,21 @@ public class UIComponentTestCase extends
{
super(testName);
}
-
+
@Override
protected void setUp() throws Exception
{
+ _mockRequestContext = new MockRequestContext();
super.setUp();
}
-
+
@Override
protected void tearDown() throws Exception
{
super.tearDown();
+ _mockRequestContext.release();
}
-
+
public static Test suite()
{
return new TestSuite(UIComponentTestCase.class);
@@ -189,7 +194,7 @@ public class UIComponentTestCase extends
UIComponent propValue = (UIComponent) mockPropValue.proxy();
mockPropValue.stubs().method("getParent").will(returnValue(null));
mockPropValue.stubs().method("setParent");
-
+
Map<String, UIComponent> facetMap = component.getFacets();
try
{
@@ -253,7 +258,7 @@ public class UIComponentTestCase extends
UIViewRoot root = new UIViewRoot();
doTestApplyRequestValues(root, component);
}
-
+
/**
* Tests the apply-request-values lifecycle phase.
*/
@@ -261,15 +266,15 @@ public class UIComponentTestCase extends
UIViewRoot root,
UIComponent component)
{
-
+
Mock mockRenderKitFactory = mock(RenderKitFactory.class);
-
+
Mock mockRenderkit = getMockRenderKitWrapper().getMock();
RenderKit renderkit = getMockRenderKitWrapper().getRenderKit();
Mock mockRenderer = mock(Renderer.class);
Renderer renderer = (Renderer) mockRenderer.proxy();
-
+
mockRenderKitFactory.stubs().method("getRenderKit").will(returnValue(renderkit));
mockRenderkit.stubs().method("getRenderer").will(returnValue(renderer));
@@ -304,10 +309,10 @@ public class UIComponentTestCase extends
UIViewRoot root,
UIComponent component)
{
-
+
Mock mock = createMockUIComponent();
UIComponent child = (UIComponent) mock.proxy();
-
+
// JavaServer Faces 1.0 Specification, section 2.2.2
// During the apply-request-values phase,
// only the processDecodes lifecycle method may be called.
@@ -318,7 +323,7 @@ public class UIComponentTestCase extends
// execute the apply-request-values lifecycle phase
if (component.getParent() == null)
root.getChildren().add(component);
-
+
component.getChildren().add(child);
AttributeChangeTester attributeChangeTester = null;
@@ -361,7 +366,7 @@ public class UIComponentTestCase extends
UIViewRoot root = new UIViewRoot();
doTestProcessValidations(root, component, submittedValue, convertedValue);
}
-
+
/**
* Tests the process-validations lifecycle phase.
*/
@@ -371,32 +376,32 @@ public class UIComponentTestCase extends
Object submittedValue,
Object convertedValue)
{
-
+
Mock mockRenderKit = getMockRenderKitWrapper().getMock();
-
+
Mock mockRenderer = mock(Renderer.class);
Renderer renderer = (Renderer) mockRenderer.proxy();
mockRenderKit.stubs().method("getRenderer").will(returnValue(renderer));
-
+
Mock mockConverter = mock(Converter.class);
Converter converter = (Converter) mockConverter.proxy();
-
+
Mock mockValidator = mock(Validator.class);
Validator validator = (Validator) mockValidator.proxy();
-
+
Mock mockListener = mock(ValueChangeListener.class);
ValueChangeListener listener = (ValueChangeListener) mockListener.proxy();
-
+
setCurrentContext(facesContext);
// if the component is an EditableValueHolder, then the submitted value
// must be converted and validated before this phase completes.
if (component instanceof EditableValueHolder)
{
-
+
EditableValueHolder editable = (EditableValueHolder)component;
mockConverter.expects(never()).method("getAsObject");
- mockConverter.expects(never()).method("getAsString");
+ mockConverter.expects(never()).method("getAsString");
mockRenderer.expects(once()).method("getConvertedValue").will(returnValue(convertedValue));
editable.setConverter(converter);
editable.setSubmittedValue(submittedValue);
@@ -414,7 +419,7 @@ public class UIComponentTestCase extends
ValueHolder holder = (ValueHolder)component;
holder.setConverter(converter);
mockConverter.expects(never()).method("getAsObject");//setExpectedGetAsObjectCalls(0);
- mockConverter.expects(never()).method("getAsString");
+ mockConverter.expects(never()).method("getAsString");
}
doTestProcessValidations(facesContext, root, component);
@@ -435,10 +440,10 @@ public class UIComponentTestCase extends
UIViewRoot root,
UIComponent component)
{
-
+
Mock mock = createMockUIComponent();
UIComponent child = (UIComponent) mock.proxy();
-
+
// JavaServer Faces 1.0 Specification, section 2.2.3
// During the process-validations phase,
// only the processValidators lifecycle method may be called.
@@ -450,7 +455,7 @@ public class UIComponentTestCase extends
if (component.getParent() == null)
root.getChildren().add(component);
component.getChildren().add(child);
-
+
root.processValidators(context);
mock.verify();
@@ -465,7 +470,7 @@ public class UIComponentTestCase extends
UIViewRoot root = new UIViewRoot();
doTestUpdateModelValues(root, component);
}
-
+
/**
* Tests the update-model-values lifecycle phase.
*/
@@ -475,11 +480,11 @@ public class UIComponentTestCase extends
{
Mock mockRenderkit = getMockRenderKitWrapper().getMock();
-
+
Mock mockRenderer = mock(Renderer.class);
Renderer renderer = (Renderer) mockRenderer.proxy();
mockRenderkit.stubs().method("getRenderer").will(returnValue(renderer));
-
+
Mock mockBinding = mock(ValueBinding.class);
ValueBinding binding = (ValueBinding) mockBinding.proxy();
@@ -560,7 +565,7 @@ public class UIComponentTestCase extends
UIComponent component,
FacesEvent event)
{
-
+
Mock mock = createMockUIComponent();
UIComponent child = (UIComponent) mock.proxy();
// JavaServer Faces 1.0 Specification, section 2.2.5
@@ -588,11 +593,11 @@ public class UIComponentTestCase extends
protected void doTestRenderResponse(
UIComponent component) throws IOException
{
-
+
// MockRenderKitFactory factory = setupMockRenderKitFactory();
-
+
Mock mockRenderkit = getMockRenderKitWrapper().getMock();
-
+
Mock mockRenderer = mock(Renderer.class);
Renderer renderer = (Renderer) mockRenderer.proxy();
mockRenderkit.stubs().method("getRenderer").will(returnValue(renderer));
@@ -600,7 +605,7 @@ public class UIComponentTestCase extends
Mock mockChild = createMockUIComponent(); //mock(UIComponent.class);
UIComponent child = (UIComponent) mockChild.proxy();
- mockChild.expects(atLeastOnce()).method("getParent").will(returnValue(null));
+ mockChild.expects(atLeastOnce()).method("getParent").will(returnValue(null));
mockChild.expects(atLeastOnce()).method("isTransient").will(returnValue(false));
mockChild.expects(atLeastOnce()).method("getRendersChildren").will(returnValue(true));
@@ -610,7 +615,7 @@ public class UIComponentTestCase extends
mockRenderer.expects(never()).method("decode");
mockRenderer.expects(never()).method("getConvertedValue");
mockRenderer.expects(never()).method("encodeChildren");
-
+
if (isRendererUsed())
{
mockRenderer.expects(once()).method("encodeBegin");
@@ -631,7 +636,7 @@ public class UIComponentTestCase extends
mockChild.expects(never()).method("processValidators");
mockChild.expects(never()).method("processUpdates");
mockChild.expects(once()).method("processSaveState");
-
+
//fix this!
mockChild.expects(once()).method("encodeBegin");
mockChild.expects(once()).method("encodeChildren");
@@ -660,21 +665,21 @@ public class UIComponentTestCase extends
UIViewRoot root)
{
// -= Simon =-
- // All those variables do not seem to be used and do not seem
+ // All those variables do not seem to be used and do not seem
// to test anything either
/*Mock mockRenderkit = getMockRenderKitWrapper().getMock();
RenderKit renderkit = getMockRenderKitWrapper().getRenderKit();
*/
Mock mockRenderer = mock(Renderer.class);
/*Renderer renderer = (Renderer) mockRenderer.proxy();
-
+
Mock mockValidator = mock(Validator.class);
Validator validator = (Validator) mockValidator.proxy();
-
+
ViewHandler viewhandler = this.facesContext.getApplication().getViewHandler();*/
setCurrentContext(facesContext);
-
+
root.processValidators(facesContext);
mockRenderer.verify();
@@ -691,7 +696,7 @@ public class UIComponentTestCase extends
protected Mock createMockUIComponent()
{
Mock mock = mock(UIComponent.class);
-
+
mock.stubs().method("getParent").will(returnValue(null));
mock.stubs().method("setParent");
mock.stubs().method("getFacetsAndChildren").will(returnIterator(Collections.emptyList()));
@@ -704,7 +709,7 @@ public class UIComponentTestCase extends
mock.expects(never()).method("encodeBegin");
mock.expects(never()).method("encodeChildren");
mock.expects(never()).method("encodeEnd");
-
+
return mock;
}
@@ -722,11 +727,12 @@ public class UIComponentTestCase extends
{
return _isRendererUsed;
}
-
+
protected void setRendererUsed(boolean isRendererUsed)
{
_isRendererUsed = isRendererUsed;
}
-
+
private boolean _isRendererUsed = true;
+ private MockRequestContext _mockRequestContext;
}
Modified: myfaces/trinidad/trunk/trinidad-api/src/test/java/org/apache/myfaces/trinidad/context/MockRequestContext.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/test/java/org/apache/myfaces/trinidad/context/MockRequestContext.java?rev=1021896&r1=1021895&r2=1021896&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/test/java/org/apache/myfaces/trinidad/context/MockRequestContext.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/test/java/org/apache/myfaces/trinidad/context/MockRequestContext.java Tue Oct 12 19:36:41 2010
@@ -20,7 +20,6 @@ package org.apache.myfaces.trinidad.cont
import java.awt.Color;
-import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
@@ -30,12 +29,7 @@ import java.util.TimeZone;
import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
-
-import javax.faces.component.visit.VisitContext;
-import javax.faces.component.visit.VisitHint;
-
import javax.faces.context.FacesContext;
-import javax.faces.event.PhaseId;
import org.apache.myfaces.trinidad.change.ChangeManager;
import org.apache.myfaces.trinidad.config.RegionManager;
@@ -342,7 +336,7 @@ public class MockRequestContext extends
@Override
public void partialUpdateNotify(UIComponent updated)
{
- throw new UnsupportedOperationException("Should not be called during rendering");
+ // Do nothing
}
@Override
Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java?rev=1021896&r1=1021895&r2=1021896&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java Tue Oct 12 19:36:41 2010
@@ -22,7 +22,6 @@ import java.awt.Color;
import java.io.Serializable;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -37,16 +36,15 @@ import javax.faces.application.ProjectSt
import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
+import javax.faces.component.visit.VisitContext;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
+import javax.faces.view.ViewDeclarationLanguage;
import org.apache.myfaces.trinidad.change.ChangeManager;
import org.apache.myfaces.trinidad.change.NullChangeManager;
import org.apache.myfaces.trinidad.change.SessionChangeManager;
import org.apache.myfaces.trinidad.component.UIXComponent;
-import javax.faces.component.visit.VisitContext;
-import javax.faces.view.ViewDeclarationLanguage;
-
import org.apache.myfaces.trinidad.config.RegionManager;
import org.apache.myfaces.trinidad.context.AccessibilityProfile;
import org.apache.myfaces.trinidad.context.Agent;
@@ -68,7 +66,6 @@ import org.apache.myfaces.trinidadintern
import org.apache.myfaces.trinidadinternal.agent.TrinidadAgentImpl;
import org.apache.myfaces.trinidadinternal.application.InternalViewHandlingStrategy;
import org.apache.myfaces.trinidadinternal.application.StateManagerImpl;
-import org.apache.myfaces.trinidadinternal.application.ViewHandlerImpl;
import org.apache.myfaces.trinidadinternal.el.FormatterMap;
import org.apache.myfaces.trinidadinternal.el.HelpProvider;
import org.apache.myfaces.trinidadinternal.el.OracleHelpProvider;
@@ -230,11 +227,11 @@ public class RequestContextImpl extends
_bean.getProperty(RequestContextBean.DEBUG_OUTPUT_KEY));
FacesContext fc = FacesContext.getCurrentInstance();
-
+
if (fc.isProjectStage(ProjectStage.Production))
{
- // on production we always want FALSE, unless the
- // user explicitly set the config to TRUE, but
+ // on production we always want FALSE, unless the
+ // user explicitly set the config to TRUE, but
// generate a WARNING message for that.
if (debugOutput)
{
@@ -727,8 +724,8 @@ public class RequestContextImpl extends
return false;
ViewDeclarationLanguage strategy = context.getApplication().
- getViewHandler().getViewDeclarationLanguage(context, root.getViewId());
-
+ getViewHandler().getViewDeclarationLanguage(context, root.getViewId());
+
return (strategy instanceof InternalViewHandlingStrategy);
}
Modified: myfaces/trinidad/trunk/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/renderkit/MRequestContext.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/renderkit/MRequestContext.java?rev=1021896&r1=1021895&r2=1021896&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/renderkit/MRequestContext.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/renderkit/MRequestContext.java Tue Oct 12 19:36:41 2010
@@ -20,7 +20,6 @@ package org.apache.myfaces.trinidadinter
import java.awt.Color;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -31,12 +30,7 @@ import java.util.TimeZone;
import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
-
-import javax.faces.component.visit.VisitContext;
-import javax.faces.component.visit.VisitHint;
-
import javax.faces.context.FacesContext;
-import javax.faces.event.PhaseId;
import org.apache.myfaces.trinidad.change.ChangeManager;
import org.apache.myfaces.trinidad.config.RegionManager;
@@ -47,7 +41,6 @@ import org.apache.myfaces.trinidad.conte
import org.apache.myfaces.trinidad.context.PageResolver;
import org.apache.myfaces.trinidad.context.RequestContext;
import org.apache.myfaces.trinidad.webapp.UploadedFileProcessor;
-import org.apache.myfaces.trinidadinternal.context.MVisitContextFactory;
import org.apache.myfaces.trinidadinternal.context.PageFlowScopeProviderImpl;
import org.apache.myfaces.trinidadinternal.context.PageResolverDefaultImpl;
Modified: myfaces/trinidad/trunk/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TableSelectOneRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TableSelectOneRendererTest.java?rev=1021896&r1=1021895&r2=1021896&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TableSelectOneRendererTest.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TableSelectOneRendererTest.java Tue Oct 12 19:36:41 2010
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -29,6 +29,7 @@ import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.myfaces.trinidad.component.core.data.CoreTable;
+import org.apache.myfaces.trinidad.context.MockRequestContext;
import org.apache.myfaces.trinidad.event.SelectionEvent;
import org.apache.myfaces.trinidad.model.RowKeySet;
import org.apache.myfaces.trinidad.model.RowKeySetImpl;
@@ -46,19 +47,21 @@ public class TableSelectOneRendererTest
{
super(testName);
}
-
+
@Override
protected void setUp() throws Exception
{
super.setUp();
+ _mockRequestContext = new MockRequestContext();
}
-
+
@Override
protected void tearDown() throws Exception
{
+ _mockRequestContext.release();
super.tearDown();
}
-
+
public static Test suite()
{
return new TestSuite(TableSelectOneRendererTest.class);
@@ -141,7 +144,7 @@ public class TableSelectOneRendererTest
TableSelectOneRenderer renderer = new TableSelectOneRenderer(CoreTable.TYPE);
mockRenderKit.expects(atLeastOnce()).method("getRenderer").will(returnValue(renderer));
-
+
if (selectedIndex >= 0)
{
int oldIndex = table.getRowIndex();
@@ -162,7 +165,7 @@ public class TableSelectOneRendererTest
renderer.decode(facesContext, table);
-
+
mockRenderKit.verify();
}
@@ -185,6 +188,8 @@ public class TableSelectOneRendererTest
public FacesEvent event = null;
}
+
+ private MockRequestContext _mockRequestContext;
private static final String _TABLE_ID = "table1";
private static final int _INIT_SELECTION = 3;
}