Class UIViewRoot
- All Implemented Interfaces:
PartialStateHolder,StateHolder,TransientStateHolder,UniqueIdVendor,ComponentSystemEventListener,FacesListener,SystemEventListenerHolder,EventListener
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(jakarta.faces.context.FacesContext)andencodeEnd(jakarta.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 correspondingPhaseIdfor this phase.Upon return from the listener, call
FacesContext.getResponseComplete()andFacesContext.getRenderResponse(). If either returntrueset the internal state flag totrue.If or one or more listeners have been added by a call to
addPhaseListener(jakarta.faces.event.PhaseListener), invoke thebeforePhasemethod on each one whosePhaseListener.getPhaseId()matches the current phaseId, passing in the samePhaseIdas in the previous step.Upon return from each listener, call
FacesContext.getResponseComplete()andFacesContext.getRenderResponse(). If either returntrueset the internal state flag totrue.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 correspondingPhaseIdfor this phase.If or one or more listeners have been added by a call to
addPhaseListener(jakarta.faces.event.PhaseListener), invoke theafterPhasemethod on each one whosePhaseListener.getPhaseId()matches the current phaseId, passing in the samePhaseIdas 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>static final StringIf this param is set, and calling toLowerCase().equals("true") on a String representation of its value returns true, exceptions thrown byPhaseListeners installed on theUIViewRootare queued to theExceptionHandlerinstead of being logged and swallowed.Fields inherited from class jakarta.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(jakarta.faces.context.FacesContext)behavior.voidencodeChildren(FacesContext context) IfPartialViewContext.isAjaxRequest()returnstrue, perform partial rendering by callingPartialViewContext.processPartial(jakarta.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) Return an unmodifiable orderedListof allUIComponentresources of all supported targets.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) voidprocessEvent(ComponentSystemEvent event) If the argumenteventis an instance ofPostRestoreStateEventandPartialViewContext.isPartialRequest()returnstrue, then loop over all component resources and callResourceHandler.markResourceRendered(FacesContext, String, String)for each of them.voidprocessRestoreState(FacesContext context, Object state) The default implementation must callUIComponentBase.processRestoreState(jakarta.faces.context.FacesContext, java.lang.Object)from within atryblock.voidprocessUpdates(FacesContext context) voidprocessValidators(FacesContext context) voidqueueEvent(FacesEvent event) Override the defaultUIComponentBase.queueEvent(jakarta.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 jakarta.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 jakarta.faces.component.UIComponent
encodeAll, getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isVisitable, popComponentFromEL, 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:
-
VIEWROOT_PHASE_LISTENER_QUEUES_EXCEPTIONS_PARAM_NAME
If this param is set, and calling toLowerCase().equals("true") on a String representation of its value returns true, exceptions thrown by
PhaseListeners installed on theUIViewRootare queued to theExceptionHandlerinstead of being logged and swallowed.- Since:
- 2.3
- 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- Returns:
trueif within a view hierarchy,falseotherwise.- Since:
- 2.0
-
setInView
public void setInView(boolean isInView) Overridden to take no action.
- Overrides:
setInViewin classUIComponent- Parameters:
isInView- ignore the value.- 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. Note this method should NOT returnnull- Specified by:
getFamilyin classUIComponent- Returns:
- the component family (not null).
- See Also:
-
getRenderKitId
Return the render kit identifier of the
RenderKitassociated with this view. Unless explicitly set, as inViewHandler.createView(jakarta.faces.context.FacesContext, java.lang.String), the returned value will benull.- Returns:
- the render kit id, or
null.
-
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.
- Returns:
- the view id.
-
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(jakarta.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(jakarta.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.- Returns:
- the list of phase listeners.
- 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(jakarta.faces.context.FacesContext, jakarta.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 valuehead -
Call
getComponentResources(jakarta.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.
The resource
Renderermust ensure of the following:- Do not render when
ResourceHandler.isResourceRendered(FacesContext, String, String)returnstrue. - After rendering, call
ResourceHandler.markResourceRendered(FacesContext, String, String).
- 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 “jakarta_faces_location_” (without the quotes) to the value of thetargetargument - Add the facet to the facets
Mapusingtargetas the key
- Set the
- return the children of the facet
- Parameters:
context- the Faces context.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
- Locate the facet for the
-
getComponentResources
Return an unmodifiable ordered
Listof allUIComponentresources of all supported targets. Eachcomponentin theListis assumed to represent a resource instance. The ordering is the same as the resources would appear in the component tree.- Parameters:
context- The Faces context.- Returns:
- A
Listof allUIComponentresources of all supported targets. If no resources are found, return an emptyList. - Throws:
NullPointerException- Ifcontextisnull.- Since:
- 2.3
-
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(jakarta.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
- If the
-
queueEvent
Override the default
UIComponentBase.queueEvent(jakarta.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(jakarta.faces.context.FacesContext, jakarta.faces.component.UIComponent)must be called before the event is broadcast, andUIComponent.popComponentFromEL(jakarta.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(jakarta.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
-
processEvent
If the argument
eventis an instance ofPostRestoreStateEventandPartialViewContext.isPartialRequest()returnstrue, then loop over all component resources and callResourceHandler.markResourceRendered(FacesContext, String, String)for each of them. Finally, delegate to super.- Specified by:
processEventin interfaceComponentSystemEventListener- Overrides:
processEventin classUIComponent- Parameters:
event- theComponentSystemEventinstance that is being processed.- Throws:
AbortProcessingException- if lifecycle processing should cease for this request.
-
processDecodes
Perform partial processing by calling
PartialViewContext.processPartial(jakarta.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(jakarta.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(jakarta.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(jakarta.faces.component.visit.VisitContext, jakarta.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(jakarta.faces.context.FacesContext)behavior. IfgetBeforePhaseListener()returns non-null, invoke it, passing aPhaseEventfor thePhaseId.RENDER_RESPONSEphase. If the internal list populated by calls toaddPhaseListener(jakarta.faces.event.PhaseListener)is non-empty, any listeners in that list must have theirPhaseListener.beforePhase(jakarta.faces.event.PhaseEvent)method called, passing thePhaseEvent. AnyExceptions that occur during invocation of any of the beforePhase listeners must be logged and swallowed, unless theVIEWROOT_PHASE_LISTENER_QUEUES_EXCEPTIONS_PARAM_NAMEparameter is set. In that case, theExceptionmust be passed to theExceptionHandleras well.- 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(jakarta.faces.event.PhaseId)withPhaseId.RENDER_RESPONSE. IfPartialViewContext.isAjaxRequest()returnsfalse, delegate to the parentUIComponentBase.encodeChildren(jakarta.faces.context.FacesContext)method.If this
UIViewRootis an instance ofNamingContainer, then the Jakarta Server Faces implementation must ensure that all encoded POST request parameter names are prefixed withUIComponent.getContainerClientId(FacesContext)as per rules ofUIComponent.getClientId(FacesContext). This also covers all predefined POST request parameters which are listed below:ResponseStateManager.VIEW_STATE_PARAMResponseStateManager.CLIENT_WINDOW_PARAMResponseStateManager.RENDER_KIT_ID_PARAMClientBehaviorContext.BEHAVIOR_SOURCE_PARAM_NAMEClientBehaviorContext.BEHAVIOR_EVENT_PARAM_NAMEPartialViewContext.PARTIAL_EVENT_PARAM_NAMEPartialViewContext.PARTIAL_EXECUTE_PARAM_NAMEPartialViewContext.PARTIAL_RENDER_PARAM_NAMEPartialViewContext.RESET_VALUES_PARAM_NAME
- 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. AnyExceptions that occur during invocation of the afterPhase listener must be logged and swallowed, unless theVIEWROOT_PHASE_LISTENER_QUEUES_EXCEPTIONS_PARAM_NAMEparameter is set. In that case, theExceptionmust be passed to theExceptionHandleras well.. If the current view has view parameters, as indicated by a non-empty and non-UnsupportedOperationExceptionthrowing return fromViewDeclarationLanguage.getViewMetadata(jakarta.faces.context.FacesContext, String), callUIViewParameter.encodeAll(jakarta.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- Returns:
trueif the component renders its children,falseotherwise.- Since:
- 2.0
-
processValidators
Perform partial processing by calling
PartialViewContext.processPartial(jakarta.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(jakarta.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(jakarta.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- See Also:
-
processUpdates
Perform partial processing by calling
PartialViewContext.processPartial(jakarta.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(jakarta.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.- Returns:
- the identifier.
-
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(jakarta.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(jakarta.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.- Returns:
- the view map, or
null. - 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(jakarta.faces.context.FacesContext, java.lang.Class<? extends jakarta.faces.event.SystemEvent>, java.lang.Object)must be called, passing the currentFacesContextas the first argument,PostConstructViewMapEvent.classas the second argument,UIViewRoot.classas the third argument and thisUIViewRootinstance as the fourth argument. It is necessary to pass theUIViewRoot.classargument to account for cases when theUIViewRoothas been extended with a custom class.The returned
Mapmust be implemented such that callingclear()on theMapcausesApplication.publishEvent(jakarta.faces.context.FacesContext, java.lang.Class<? extends jakarta.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(jakarta.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.- Returns:
- the view map, or
null. - 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(jakarta.faces.event.SystemEvent)method must be called when events of typesystemEventClassare fired.- Throws:
NullPointerException- ifsystemEventClassorlistenerarenull.- 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(jakarta.faces.event.SystemEvent)method must be called when events of typesystemEventClassare fired.- Throws:
NullPointerException- ifsystemEventClassorlistenerarenull.- 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.- Returns:
- Collection of view listeners.
- 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(jakarta.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- Parameters:
context- the Faces context.- Returns:
- the saved state.
-
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(jakarta.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- Parameters:
context- the Faces context.state- the state.
-