org.apache.myfaces.trinidad.context
Class ComponentContextManager

java.lang.Object
  extended by org.apache.myfaces.trinidad.context.ComponentContextManager

public abstract class ComponentContextManager
extends Object

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 UIComponent.invokeOnComponent(javax.faces.context.FacesContext, java.lang.String, javax.faces.component.ContextCallback) or UIComponent.visitTree(javax.faces.component.visit.VisitContext, javax.faces.component.visit.VisitCallback) call in the proper context.

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.

The changes are automatically suspended during an invoke on component or visit tree invocation. This work is performed by the trh:head, trh:body and the tr:document components. Components outside of these components are not restore to the root context.


Constructor Summary
ComponentContextManager()
           
 
Method Summary
abstract  SuspendedContextChanges partialSuspend(javax.faces.context.FacesContext facesContext, SuspendCallback callback)
          Suspend the changes on the stack to an arbitrary point.
abstract  ComponentContextChange peekChange()
          Get the latest change on the stack without removing it.
abstract  ComponentContextChange popChange()
          Remove the latest change from the stack.
abstract  void pushChange(ComponentContextChange change)
          Push a change onto the stack.
abstract  Iterator<ComponentContextChange> resume(javax.faces.context.FacesContext facesContext, SuspendedContextChanges suspendedChanges)
          Resume a set of suspended changes.
abstract  SuspendedContextChanges suspend(javax.faces.context.FacesContext facesContext)
          Suspend the entire stack of context changes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComponentContextManager

public ComponentContextManager()
Method Detail

pushChange

public abstract void pushChange(ComponentContextChange change)
Push a change onto the stack.

Parameters:
change - The change to push

popChange

public abstract ComponentContextChange popChange()
                                          throws IllegalStateException
Remove the latest change from the stack.

Returns:
the change that has been removed from the stack
Throws:
IllegalStateException - if an attempt is made to pop an empty stack

peekChange

public abstract ComponentContextChange peekChange()
Get the latest change on the stack without removing it.

Returns:
the latest change or null if none

suspend

public abstract SuspendedContextChanges suspend(javax.faces.context.FacesContext facesContext)
Suspend the entire stack of context changes. Used by the document to clear all changes during an invoke on component or visit tree call.

Parameters:
facesContext - The faces context
Returns:
an object to use to pass back to the resume(javax.faces.context.FacesContext, org.apache.myfaces.trinidad.context.SuspendedContextChanges) method to resume the suspend changes at a later time

partialSuspend

public abstract SuspendedContextChanges partialSuspend(javax.faces.context.FacesContext facesContext,
                                                       SuspendCallback callback)
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.

Parameters:
facesContext - the faces context
callback - a callback interface used to determine how far back to suspend.
Returns:
an object to use to pass back to the resume(javax.faces.context.FacesContext, org.apache.myfaces.trinidad.context.SuspendedContextChanges) method to resume the suspend changes at a later time

resume

public abstract Iterator<ComponentContextChange> resume(javax.faces.context.FacesContext facesContext,
                                                        SuspendedContextChanges suspendedChanges)
Resume a set of suspended changes.

Parameters:
facesContext - the faces context
suspendedChanges - a set of changes that have been previously suspended
Returns:
Iterator of changes that were resumed during the call (iterates in the earliest to most recent order).


Copyright © 2001-2012 The Apache Software Foundation. All Rights Reserved.