Class UIViewRoot
- All Implemented Interfaces:
EventListener,PartialStateHolder,StateHolder,TransientStateHolder,UniqueIdVendor,ComponentSystemEventListener,FacesListener,SystemEventListenerHolder
UIViewRoot is the UIComponent
that represents the root of the UIComponent tree. This component
renders markup as the response to Ajax requests. It also serves as
the root of the component tree, and as a place to hang per-view
PhaseListeners.
For each of the following lifecycle phase methods:
RenderResponse, via
encodeBegin(javax.faces.context.FacesContext)andencodeEnd(javax.faces.context.FacesContext)
Take the following action regarding
PhaseListeners.
Initialize a state flag to false.
If getBeforePhaseListener() returns non-null,
invoke the listener, passing in the correct corresponding PhaseId for this phase.
Upon return from the listener, call FacesContext.getResponseComplete() and FacesContext.getRenderResponse(). If either return true
set the internal state flag to true.
If or one or more listeners have been added by a call to addPhaseListener(javax.faces.event.PhaseListener), invoke the beforePhase method on
each one whose PhaseListener.getPhaseId() matches the current
phaseId, passing in the same PhaseId as in the previous
step.
Upon return from each listener, call FacesContext.getResponseComplete() and FacesContext.getRenderResponse(). If either return true
set the internal state flag to true.
Execute any processing for this phase if the internal state flag was not set.
If getAfterPhaseListener() returns non-null,
invoke the listener, passing in the correct corresponding PhaseId for this phase.
If or one or more listeners have been added by a call to addPhaseListener(javax.faces.event.PhaseListener), invoke the afterPhase method on each
one whose PhaseListener.getPhaseId() matches the current
phaseId, passing in the same PhaseId as in the previous
step.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe standard component family for this component.static final StringThe standard component type for this component.static final Stringstatic final StringThe prefix that will be used for identifiers generated by thecreateUniqueId()method.static final StringThe key in the value set of the view metadata BeanDescriptor, the value of which is aList<.UIViewParameter.Reference>Fields inherited from class javax.faces.component.UIComponent
ATTRS_WITH_DECLARED_DEFAULT_VALUES, BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, CURRENT_COMPONENT, CURRENT_COMPOSITE_COMPONENT, FACETS_KEY, HONOR_CURRENT_COMPONENT_ATTRIBUTES_PARAM_NAME, VIEW_LOCATION_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddComponentResource(FacesContext context, UIComponent componentResource) Add argumentcomponent, which is assumed to represent a resource instance, as a resource to this view.voidaddComponentResource(FacesContext context, UIComponent componentResource, String target) Add argumentcomponent, which is assumed to represent a resource instance, as a resource to this view.voidaddPhaseListener(PhaseListener newPhaseListener) voidbroadcastEvents(FacesContext context, PhaseId phaseId) Broadcast any events that have been queued.Generate an identifier for a component.createUniqueId(FacesContext context, String seed) Generate an identifier for a component.voidencodeBegin(FacesContext context) Override the defaultUIComponentBase.encodeBegin(javax.faces.context.FacesContext)behavior.voidencodeChildren(FacesContext context) IfPartialViewContext.isAjaxRequest()returnstrue, perform partial rendering by callingPartialViewContext.processPartial(javax.faces.event.PhaseId)withPhaseId.RENDER_RESPONSE.voidencodeEnd(FacesContext context) IfgetAfterPhaseListener()returns non-null, invoke it, passing aPhaseEventfor thePhaseId.RENDER_RESPONSEphase.Return theMethodExpressionthat will be invoked after this view is rendered.Return theMethodExpressionthat will be invoked before this view is rendered.getComponentResources(FacesContext context, String target) Return the identifier of the component family to which this component belongs.Return theLocaleto be used in localizing the response being created for this view.Return an unmodifiable list of thePhaseListenerinstances attached to thisUIViewRootinstance.Return the render kit identifier of theRenderKitassociated with this view.booleanCallUIComponentBase.getRendersChildren()IfPartialViewContext.isAjaxRequest()returnstruethis method must returntrue.Return the view identifier for this view.getViewListenersForEventClass(Class<? extends SystemEvent> systemEvent) Return theSystemEventListenerinstances registered on thisUIComponentinstance that are interested in events of typeeventClass.This implementation simply calls through togetViewMap(boolean), passingtrueas the argument, and returns the result.getViewMap(boolean create) Returns aMapthat acts as the interface to the data store that is the "view scope", or, if this instance does not have such aMapand thecreateargument istrue, creates one and returns it.booleanisInView()Override superclass method to always returntruebecause aUIViewRootis defined to always be in a view.voidprocessApplication(FacesContext context) Broadcast any events that have been queued for the Invoke Application phase of the request processing lifecycle and to clear out any events for later phases if the event processing for this phase causedFacesContext.renderResponse()orFacesContext.responseComplete()to be called.voidprocessDecodes(FacesContext context) voidprocessRestoreState(FacesContext context, Object state) The default implementation must callUIComponentBase.processRestoreState(javax.faces.context.FacesContext, java.lang.Object)from within atryblock.voidprocessUpdates(FacesContext context) voidprocessValidators(FacesContext context) voidqueueEvent(FacesEvent event) Override the defaultUIComponentBase.queueEvent(javax.faces.event.FacesEvent)behavior to accumulate the queued events for later broadcasting.voidremoveComponentResource(FacesContext context, UIComponent componentResource) Remove argumentcomponent, which is assumed to represent a resource instance, as a resource to this view.voidremoveComponentResource(FacesContext context, UIComponent componentResource, String target) Remove argumentcomponent, which is assumed to represent a resource instance, as a resource to this view.voidremovePhaseListener(PhaseListener toRemove) If the argumenttoRemoveis in the list ofPhaseListeners for this instance, it must be removed.voidresetValues(FacesContext context, Collection<String> clientIds) Visit the clientIds and, if the component is an instance ofEditableValueHolder, call itsEditableValueHolder.resetValue()method.voidrestoreState(FacesContext context, Object state) Perform any processing required to restore the state from the entries in the state Object.voidrestoreViewScopeState(FacesContext context, Object state) Restore ViewScope state.saveState(FacesContext context) Gets the state of the instance as aSerializableObject.voidsetAfterPhaseListener(MethodExpression newAfterPhase) Allow an arbitrary method to be called for the "afterPhase" event as the UIViewRoot runs through its lifecycle.voidsetBeforePhaseListener(MethodExpression newBeforePhase) Allow an arbitrary method to be called for the "beforePhase" event as the UIViewRoot runs through its lifecycle.voidsetInView(boolean isInView) Overridden to take no action.voidSet theLocaleto be used in localizing the response being created for this view.voidsetRenderKitId(String renderKitId) Set the render kit identifier of theRenderKitassociated with this view.voidSet the view identifier for this view.voidsubscribeToViewEvent(Class<? extends SystemEvent> systemEvent, SystemEventListener listener) Install the listener instance referenced by argumentlistenerinto theUIViewRootas a listener for events of typesystemEventClass.voidunsubscribeFromViewEvent(Class<? extends SystemEvent> systemEvent, SystemEventListener listener) Remove the listener instance referenced by argumentlistenerfrom theUIViewRootas a listener for events of typesystemEventClass.Methods inherited from class javax.faces.component.UIComponentBase
addClientBehavior, addFacesListener, broadcast, clearInitialState, decode, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getListenersForEventClass, getParent, getPassThroughAttributes, getRenderer, getRendererType, getValueBinding, invokeOnComponent, isRendered, isTransient, markInitialState, processSaveState, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding, subscribeToEvent, unsubscribeFromEventMethods inherited from class javax.faces.component.UIComponent
encodeAll, getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, restoreTransientState, saveTransientState, setValueExpression, visitTree
-
Field Details
-
METADATA_FACET_NAME
- See Also:
-
VIEW_PARAMETERS_KEY
The key in the value set of the view metadata BeanDescriptor, the value of which is a
List<.UIViewParameter.Reference>- Since:
- 2.0
- See Also:
-
COMPONENT_TYPE
The standard component type for this component.
- See Also:
-
COMPONENT_FAMILY
The standard component family for this component.
- See Also:
-
UNIQUE_ID_PREFIX
The prefix that will be used for identifiers generated by the
createUniqueId()method.- See Also:
-
-
Constructor Details
-
UIViewRoot
public UIViewRoot()Create a new
UIViewRootinstance with default property values.
-
-
Method Details
-
isInView
public boolean isInView()Override superclass method to always return
truebecause aUIViewRootis defined to always be in a view.- Overrides:
isInViewin classUIComponent- Since:
- 2.0
-
setInView
public void setInView(boolean isInView) Overridden to take no action.
- Overrides:
setInViewin classUIComponent- Parameters:
isInView-- Since:
- 2.0
-
getFamily
Description copied from class:UIComponentReturn the identifier of the component family to which this component belongs. This identifier, in conjunction with the value of the
rendererTypeproperty, may be used to select the appropriateRendererfor this component instance.- Specified by:
getFamilyin classUIComponent- See Also:
-
getRenderKitId
Return the render kit identifier of the
RenderKitassociated with this view. Unless explicitly set, as inViewHandler.createView(javax.faces.context.FacesContext, java.lang.String), the returned value will benull. -
setRenderKitId
Set the render kit identifier of the
RenderKitassociated with this view. This method may be called at any time between the end of Apply Request Values phase of the request processing lifecycle (i.e. when events are being broadcast) and the beginning of the Render Response phase. -
getViewId
Return the view identifier for this view.
-
setViewId
Set the view identifier for this view.
- Parameters:
viewId- The new view identifier
-
getBeforePhaseListener
Return the
MethodExpressionthat will be invoked before this view is rendered.- Returns:
- the
MethodExpressionthat will be invoked before this view is rendered. - Since:
- 1.2
-
setBeforePhaseListener
Allow an arbitrary method to be called for the "beforePhase" event as the UIViewRoot runs through its lifecycle. This method will be called for all phases except
PhaseId.RESTORE_VIEW. Unlike a truePhaseListener, this approach doesn't allow for only receivingPhaseEvents for a given phase.The method must conform to the signature of
PhaseListener.beforePhase(javax.faces.event.PhaseEvent).- Parameters:
newBeforePhase- theMethodExpressionthat will be invoked before this view is rendered.- Since:
- 1.2
-
getAfterPhaseListener
Return the
MethodExpressionthat will be invoked after this view is rendered.- Returns:
- the
MethodExpressionthat will be invoked after this view is rendered. - Since:
- 1.2
-
setAfterPhaseListener
Allow an arbitrary method to be called for the "afterPhase" event as the UIViewRoot runs through its lifecycle. This method will be called for all phases including
PhaseId.RESTORE_VIEW. Unlike a truePhaseListener, this approach doesn't allow for only receivingPhaseEvents for a given phase.The method must conform to the signature of
PhaseListener.afterPhase(javax.faces.event.PhaseEvent).- Parameters:
newAfterPhase- theMethodExpressionthat will be invoked after this view is rendered.- Since:
- 1.2
-
removePhaseListener
If the argument
toRemoveis in the list ofPhaseListeners for this instance, it must be removed.- Parameters:
toRemove- thePhaseListenerto remove.- Since:
- 1.2
-
addPhaseListener
Add the argument
newPhaseListenerto the list ofPhaseListeners on thisUIViewRoot.- Parameters:
newPhaseListener- thePhaseListenerto add- Since:
- 1.2
-
getPhaseListeners
Return an unmodifiable list of the
PhaseListenerinstances attached to thisUIViewRootinstance.- Since:
- 2.0
-
addComponentResource
Add argument
component, which is assumed to represent a resource instance, as a resource to this view. A resource instance is rendered by a resourceRenderer, as described in the Standard HTML RenderKit. The default implementation must call through toaddComponentResource(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String).- Parameters:
context-FacesContextfor the current requestcomponentResource- TheUIComponentrepresenting aResourceinstance- Since:
- 2.0
addComponentResource
public void addComponentResource(FacesContext context, UIComponent componentResource, String target) Add argument
component, which is assumed to represent a resource instance, as a resource to this view. A resource instance is rendered by a resourceRenderer, as described in the Standard HTML RenderKit.The
componentmust be added using the following algorithm:If the
targetargument isnull, look for atargetattribute on thecomponent. If there is notargetattribute, settargetto be the default valueheadCall
getComponentResources(javax.faces.context.FacesContext, java.lang.String)to obtain the child list for the given target.If the component ID of
componentResourcematches the the ID of a resource that has allready been added, remove the old resource.Add the
componentresource to the list.
- Parameters:
context-FacesContextfor the current requestcomponentResource- TheUIComponentrepresenting aResourceinstancetarget- The name of the facet for which theUIComponentwill be added- Since:
- 2.0
getComponentResources
Return an unmodifiable
ListofUIComponents for the providedtargetagrument. Eachcomponentin theListis assumed to represent a resource instance.The default implementation must use an algorithm equivalent to the the following.
- Locate the facet for the
componentby callinggetFacet()usingtargetas the argument. - If the facet is not found, create the facet by calling
context.getApplication().createComponent().The argument to this method must refer to a component that extendsUIPaneland overrides theencodeAll()method to take no action. This is necessary to prevent component resources from being inadvertently rendered. - Set the
idof the facet to be a string created by prepending the literal string “javax_faces_location_” (without the quotes) to the value of thetargetargument - Add the facet to the facets
Mapusingtargetas the key - return the children of the facet
- Parameters:
target- The name of the facet for which the components will be returned.- Returns:
- A
ListofUIComponentchildren of the facet with the nametarget. If no children are found for the facet, returnCollections.emptyList(). - Throws:
NullPointerException- iftargetorcontextisnull- Since:
- 2.0
removeComponentResource
Remove argument
component, which is assumed to represent a resource instance, as a resource to this view.- Parameters:
context-FacesContextfor the current requestcomponentResource- TheUIComponentrepresenting aResourceinstance- Since:
- 2.0
removeComponentResource
public void removeComponentResource(FacesContext context, UIComponent componentResource, String target) Remove argument
component, which is assumed to represent a resource instance, as a resource to this view. A resource instance is rendered by a resourceRenderer, as described in the Standard HTML RenderKit.The
componentmust be removed using the following algorithm:- If the
targetargument isnull, look for atargetattribute on thecomponent.
If there is notargetattribute, settargetto be the default valuehead - Call
getComponentResources(javax.faces.context.FacesContext, java.lang.String)to obtain the child list for the given target. - Remove the
componentresource from the child list.
- Parameters:
context-FacesContextfor the current requestcomponentResource- TheUIComponentrepresenting aResourceinstancetarget- The name of the facet for which theUIComponentwill be added- Since:
- 2.0
queueEvent
Override the default
UIComponentBase.queueEvent(javax.faces.event.FacesEvent)behavior to accumulate the queued events for later broadcasting.- Overrides:
queueEventin classUIComponentBase- Parameters:
event-FacesEventto be queued- Throws:
IllegalStateException- if this component is not a descendant of aUIViewRootNullPointerException- ifeventisnull
broadcastEvents
Broadcast any events that have been queued. First broadcast events that have been queued for
PhaseId.ANY_PHASE. Then broadcast ane events that have been queued for the current phase. In both cases,UIComponent.pushComponentToEL(javax.faces.context.FacesContext, javax.faces.component.UIComponent)must be called before the event is broadcast, andUIComponent.popComponentFromEL(javax.faces.context.FacesContext)must be called after the return from the broadcast, even in the case of an exception.- Parameters:
context-FacesContextfor the current requestphaseId-PhaseIdof the current phase- Since:
- 2.0
processRestoreState
The default implementation must call
UIComponentBase.processRestoreState(javax.faces.context.FacesContext, java.lang.Object)from within atryblock. Thetryblock must have afinallyblock that ensures that noFacesEvents remain in the event queue.- Overrides:
processRestoreStatein classUIComponentBase- Parameters:
context- theFacesContextfor this requetsstate- the opaque state object obtained from theStateManager
processDecodes
Perform partial processing by calling
PartialViewContext.processPartial(javax.faces.event.PhaseId)withPhaseId.APPLY_REQUEST_VALUESif:PartialViewContext.isPartialRequest()returnstrueand we don't have a request to process all components in the view (PartialViewContext.isExecuteAll()returnsfalse)
UIComponentBase.processDecodes(javax.faces.context.FacesContext)if one of the following conditions are met:-
PartialViewContext.isPartialRequest()returnstrueand we have a request to process all components in the view (PartialViewContext.isExecuteAll()returnstrue) PartialViewContext.isPartialRequest()returnsfalse
Override the default
UIComponentBase.processDecodes(javax.faces.context.FacesContext)behavior to broadcast any queued events after the default processing or partial processing has been completed and to clear out any events for later phases if the event processing for this phase causedFacesContext.renderResponse()orFacesContext.responseComplete()to be called.- Overrides:
processDecodesin classUIComponentBase- Parameters:
context-FacesContextfor the request we are processing- Throws:
NullPointerException- ifcontextisnull
resetValues
Visit the clientIds and, if the component is an instance of
EditableValueHolder, call itsEditableValueHolder.resetValue()method. UseUIComponent.visitTree(javax.faces.component.visit.VisitContext, javax.faces.component.visit.VisitCallback)to do the visiting.- Parameters:
context- theFacesContextfor the request we are processing.clientIds- The client ids to be visited, on which the described action will be taken.- Since:
- 2.2
encodeBegin
Override the default
UIComponentBase.encodeBegin(javax.faces.context.FacesContext)behavior. IfgetBeforePhaseListener()returns non-null, invoke it, passing aPhaseEventfor thePhaseId.RENDER_RESPONSEphase. If the internal list populated by calls toaddPhaseListener(javax.faces.event.PhaseListener)is non-empty, any listeners in that list must have theirPhaseListener.beforePhase(javax.faces.event.PhaseEvent)method called, passing thePhaseEvent. Any errors that occur during invocation of any of the the beforePhase listeners must be logged and swallowed. After listeners are invoked call superclass processing.- Overrides:
encodeBeginin classUIComponentBase- Parameters:
context-FacesContextfor the response we are creating- Throws:
IOException- if an input/output error occurs while rendering
encodeChildren
If
PartialViewContext.isAjaxRequest()returnstrue, perform partial rendering by callingPartialViewContext.processPartial(javax.faces.event.PhaseId)withPhaseId.RENDER_RESPONSE. IfPartialViewContext.isAjaxRequest()returnsfalse, delegate to the parentUIComponentBase.encodeChildren(javax.faces.context.FacesContext)method.- Overrides:
encodeChildrenin classUIComponentBase- Parameters:
context-FacesContextfor the response we are creating- Throws:
IOException- if an input/output error occurs while rendering- Since:
- 2.0
encodeEnd
If
getAfterPhaseListener()returns non-null, invoke it, passing aPhaseEventfor thePhaseId.RENDER_RESPONSEphase. Any errors that occur during invocation of the afterPhase listener must be logged and swallowed. If the current view has view parameters, as indicated by a non-empty and non-UnsupportedOperationExceptionthrowing return fromViewDeclarationLanguage.getViewMetadata(javax.faces.context.FacesContext, String), callUIViewParameter.encodeAll(javax.faces.context.FacesContext)on each parameter. If callinggetViewParameters()causesUnsupportedOperationExceptionto be thrown, the exception must be silently swallowed.- Overrides:
encodeEndin classUIComponentBase- Parameters:
context-FacesContextfor the response we are creating- Throws:
IOException- if an input/output error occurs while rendering
getRendersChildren
public boolean getRendersChildren()Call
UIComponentBase.getRendersChildren()IfPartialViewContext.isAjaxRequest()returnstruethis method must returntrue.- Overrides:
getRendersChildrenin classUIComponentBase- Since:
- 2.0
processValidators
Perform partial processing by calling
PartialViewContext.processPartial(javax.faces.event.PhaseId)withPhaseId.PROCESS_VALIDATIONSif:PartialViewContext.isPartialRequest()returnstrueand we don't have a request to process all components in the view (PartialViewContext.isExecuteAll()returnsfalse)
UIComponentBase.processValidators(javax.faces.context.FacesContext)if one of the following conditions are met:-
PartialViewContext.isPartialRequest()returnstrueand we have a request to process all components in the view (PartialViewContext.isExecuteAll()returnstrue) PartialViewContext.isPartialRequest()returnsfalse
Override the default
UIComponentBase.processValidators(javax.faces.context.FacesContext)behavior to broadcast any queued events after the default processing or partial processing has been completed and to clear out any events for later phases if the event processing for this phase causedFacesContext.renderResponse()orFacesContext.responseComplete()to be called.- Overrides:
processValidatorsin classUIComponentBase- Parameters:
context-FacesContextfor the request we are processing- Throws:
NullPointerException- ifcontextisnull
processUpdates
Perform partial processing by calling
PartialViewContext.processPartial(javax.faces.event.PhaseId)withPhaseId.UPDATE_MODEL_VALUESif:PartialViewContext.isPartialRequest()returnstrueand we don't have a request to process all components in the view (PartialViewContext.isExecuteAll()returnsfalse)
UIComponentBase.processUpdates(javax.faces.context.FacesContext)if one of the following conditions are met:-
PartialViewContext.isPartialRequest()returnstrueand we have a request to process all components in the view (PartialViewContext.isExecuteAll()returnstrue) PartialViewContext.isPartialRequest()returnsfalse
Override the default
UIComponentBasebehavior to broadcast any queued events after the default processing or partial processing has been completed and to clear out any events for later phases if the event processing for this phase causedFacesContext.renderResponse()orFacesContext.responseComplete()to be called.- Overrides:
processUpdatesin classUIComponentBase- Parameters:
context-FacesContextfor the request we are processing- Throws:
NullPointerException- ifcontextisnull
processApplication
Broadcast any events that have been queued for the Invoke Application phase of the request processing lifecycle and to clear out any events for later phases if the event processing for this phase caused
FacesContext.renderResponse()orFacesContext.responseComplete()to be called.- Parameters:
context-FacesContextfor the request we are processing- Throws:
NullPointerException- ifcontextisnull
createUniqueId
Generate an identifier for a component. The identifier will be prefixed with UNIQUE_ID_PREFIX, and will be unique within the non-
NamingContainerchild sub-trees of this UIViewRoot.createUniqueId
Generate an identifier for a component. The identifier will be prefixed with UNIQUE_ID_PREFIX, and will be unique within this UIViewRoot. Optionally, a unique seed value can be supplied by component creators which should be included in the generated unique id.
- Specified by:
createUniqueIdin interfaceUniqueIdVendor- Parameters:
context- FacesContextseed- an optional seed value - e.g. based on the position of the component in the VDL-template- Returns:
- a unique-id in this component-container
getLocale
Return the
Localeto be used in localizing the response being created for this view.Algorithm:
If we have a
localeivar, return it. If we have a value expression for "locale", get its value. If the value isnull, return the result of callingViewHandler.calculateLocale(javax.faces.context.FacesContext). If the value is an instance ofjava.util.Localereturn it. If the value is a String, convert it to ajava.util.Localeand return it. If there is no value expression for "locale", return the result of callingViewHandler.calculateLocale(javax.faces.context.FacesContext).- Returns:
- The current
Localeobtained by executing the above algorithm.
setLocale
Set the
Localeto be used in localizing the response being created for this view.- Parameters:
locale- The new localization Locale
getViewMap
This implementation simply calls through to
getViewMap(boolean), passingtrueas the argument, and returns the result.- Since:
- 2.0
getViewMap
Returns a
Mapthat acts as the interface to the data store that is the "view scope", or, if this instance does not have such aMapand thecreateargument istrue, creates one and returns it. This map must be instantiated lazily and cached for return from subsequent calls to this method on thisUIViewRootinstance.Application.publishEvent(javax.faces.context.FacesContext, java.lang.Class<? extends javax.faces.event.SystemEvent>, java.lang.Object)must be called, passingPostConstructViewMapEvent.classas the first argument and thisUIViewRootinstance as the second argument.The returned
Mapmust be implemented such that callingclear()on theMapcausesApplication.publishEvent(javax.faces.context.FacesContext, java.lang.Class<? extends javax.faces.event.SystemEvent>, java.lang.Object)to be called, passingPreDestroyViewMapEvent.classas the first argument and thisUIViewRootinstance as the second argument.Depending upon application configuration, objects stored in the view map may need to be
Serializable. In general, it is a good idea to ensure that any objects stored in the view map areSerializable.For reasons made clear in
ViewScoped, this map must ultimately be stored in the session. For this reason, atruevalue for thecreateargument will force the session to be created with a call toExternalContext.getSession(boolean).See
FacesContext.setViewRoot(javax.faces.component.UIViewRoot)for the specification of when theclear()method must be called.- Parameters:
create-trueto create a newMapfor this instance if necessary;falseto returnnullif there's no currentMap.- Since:
- 2.0
subscribeToViewEvent
public void subscribeToViewEvent(Class<? extends SystemEvent> systemEvent, SystemEventListener listener) Install the listener instance referenced by argument
listenerinto theUIViewRootas a listener for events of typesystemEventClass.Note that installed listeners are not maintained as part of the
UIViewRoot's state.- Parameters:
systemEvent- theClassof event for whichlistenermust be fired.listener- the implementation ofSystemEventListenerwhoseSystemEventListener.processEvent(javax.faces.event.SystemEvent)method must be called when events of typesystemEventClassare fired.- Since:
- 2.0
unsubscribeFromViewEvent
public void unsubscribeFromViewEvent(Class<? extends SystemEvent> systemEvent, SystemEventListener listener) Remove the listener instance referenced by argument
listenerfrom theUIViewRootas a listener for events of typesystemEventClass.- Parameters:
systemEvent- theClassof event for whichlistenermust be fired.listener- the implementation ofSystemEventListenerwhoseSystemEventListener.processEvent(javax.faces.event.SystemEvent)method must be called when events of typesystemEventClassare fired.- Since:
- 2.0
getViewListenersForEventClass
public List<SystemEventListener> getViewListenersForEventClass(Class<? extends SystemEvent> systemEvent) Return the
SystemEventListenerinstances registered on thisUIComponentinstance that are interested in events of typeeventClass.- Parameters:
systemEvent- theClassof event for which the listeners must be returned.- Throws:
NullPointerException- if argumentsystemEventisnull.- Since:
- 2.0
restoreViewScopeState
Restore ViewScope state. This is needed to allow the use of view scoped beans for EL-expressions in the template from which the component tree is built. For example:
<ui:include src="#{viewScopedBean.includeFileName}"/>.- Parameters:
context- current FacesContext.state- the state object.
saveState
Description copied from interface:StateHolderGets the state of the instance as a
SerializableObject.If the class that implements this interface has references to instances that implement StateHolder (such as a
UIComponentwith event handlers, validators, etc.) this method must call theStateHolder.saveState(javax.faces.context.FacesContext)method on all those instances as well. This method must not save the state of children and facets. That is done via theStateManagerThis method must not alter the state of the implementing object. In other words, after executing this code:
Object state = component.saveState(facesContext);
componentshould be the same as before executing it.The return from this method must be
Serializable- Specified by:
saveStatein interfaceStateHolder- Overrides:
saveStatein classUIComponentBase
restoreState
Description copied from interface:StateHolderPerform any processing required to restore the state from the entries in the state Object.
If the class that implements this interface has references to instances that also implement StateHolder (such as a
UIComponentwith event handlers, validators, etc.) this method must call theStateHolder.restoreState(javax.faces.context.FacesContext, java.lang.Object)method on all those instances as well.If the
stateargument isnull, take no action and return.- Specified by:
restoreStatein interfaceStateHolder- Overrides:
restoreStatein classUIComponentBase
-