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 PhaseListener
s.
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 PhaseListener
s.
Initialize a state flag to
false
.If
getBeforePhaseListener()
returns non-null
, invoke the listener, passing in the correct correspondingPhaseId
for this phase.Upon return from the listener, call
FacesContext.getResponseComplete()
andFacesContext.getRenderResponse()
. If either returntrue
set the internal state flag totrue
.If or one or more listeners have been added by a call to
addPhaseListener(jakarta.faces.event.PhaseListener)
, invoke thebeforePhase
method on each one whosePhaseListener.getPhaseId()
matches the current phaseId, passing in the samePhaseId
as in the previous step.Upon return from each listener, call
FacesContext.getResponseComplete()
andFacesContext.getRenderResponse()
. If either returntrue
set 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 correspondingPhaseId
for this phase.If or one or more listeners have been added by a call to
addPhaseListener(jakarta.faces.event.PhaseListener)
, invoke theafterPhase
method on each one whosePhaseListener.getPhaseId()
matches the current phaseId, passing in the samePhaseId
as in the previous step.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The standard component family for this component.static final String
The standard component type for this component.static final String
static final String
The prefix that will be used for identifiers generated by thecreateUniqueId()
method.static final String
The key in the value set of the view metadata BeanDescriptor, the value of which is aList<
.UIViewParameter.Reference
>static final String
If this param is set, and calling toLowerCase().equals("true") on a String representation of its value returns true, exceptions thrown byPhaseListener
s installed on theUIViewRoot
are queued to theExceptionHandler
instead 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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addComponentResource
(FacesContext context, UIComponent componentResource) Add argumentcomponent
, which is assumed to represent a resource instance, as a resource to this view.void
addComponentResource
(FacesContext context, UIComponent componentResource, String target) Add argumentcomponent
, which is assumed to represent a resource instance, as a resource to this view.void
addPhaseListener
(PhaseListener newPhaseListener) void
broadcastEvents
(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.void
encodeBegin
(FacesContext context) Override the defaultUIComponentBase.encodeBegin(jakarta.faces.context.FacesContext)
behavior.void
encodeChildren
(FacesContext context) IfPartialViewContext.isAjaxRequest()
returnstrue
, perform partial rendering by callingPartialViewContext.processPartial(jakarta.faces.event.PhaseId)
withPhaseId.RENDER_RESPONSE
.void
encodeEnd
(FacesContext context) IfgetAfterPhaseListener()
returns non-null
, invoke it, passing aPhaseEvent
for thePhaseId.RENDER_RESPONSE
phase.Return theMethodExpression
that will be invoked after this view is rendered.Return theMethodExpression
that will be invoked before this view is rendered.getComponentResources
(FacesContext context) Return an unmodifiable orderedList
of allUIComponent
resources of all supported targets.getComponentResources
(FacesContext context, String target) Return the identifier of the component family to which this component belongs.Return theLocale
to be used in localizing the response being created for this view.Return an unmodifiable list of thePhaseListener
instances attached to thisUIViewRoot
instance.Return the render kit identifier of theRenderKit
associated with this view.boolean
CallUIComponentBase.getRendersChildren()
IfPartialViewContext.isAjaxRequest()
returnstrue
this method must returntrue
.Return the view identifier for this view.getViewListenersForEventClass
(Class<? extends SystemEvent> systemEvent) Return theSystemEventListener
instances registered on thisUIComponent
instance that are interested in events of typeeventClass
.This implementation simply calls through togetViewMap(boolean)
, passingtrue
as the argument, and returns the result.getViewMap
(boolean create) Returns aMap
that acts as the interface to the data store that is the "view scope", or, if this instance does not have such aMap
and thecreate
argument istrue
, creates one and returns it.boolean
isInView()
Override superclass method to always returntrue
because aUIViewRoot
is defined to always be in a view.void
processApplication
(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.void
processDecodes
(FacesContext context) void
processEvent
(ComponentSystemEvent event) If the argumentevent
is an instance ofPostRestoreStateEvent
andPartialViewContext.isPartialRequest()
returnstrue
, then loop over all component resources and callResourceHandler.markResourceRendered(FacesContext, String, String)
for each of them.void
processRestoreState
(FacesContext context, Object state) The default implementation must callUIComponentBase.processRestoreState(jakarta.faces.context.FacesContext, java.lang.Object)
from within atry
block.void
processUpdates
(FacesContext context) void
processValidators
(FacesContext context) void
queueEvent
(FacesEvent event) Override the defaultUIComponentBase.queueEvent(jakarta.faces.event.FacesEvent)
behavior to accumulate the queued events for later broadcasting.void
removeComponentResource
(FacesContext context, UIComponent componentResource) Remove argumentcomponent
, which is assumed to represent a resource instance, as a resource to this view.void
removeComponentResource
(FacesContext context, UIComponent componentResource, String target) Remove argumentcomponent
, which is assumed to represent a resource instance, as a resource to this view.void
removePhaseListener
(PhaseListener toRemove) If the argumenttoRemove
is in the list ofPhaseListener
s for this instance, it must be removed.void
resetValues
(FacesContext context, Collection<String> clientIds) Visit the clientIds and, if the component is an instance ofEditableValueHolder
, call itsEditableValueHolder.resetValue()
method.void
restoreState
(FacesContext context, Object state) Perform any processing required to restore the state from the entries in the state Object.void
restoreViewScopeState
(FacesContext context, Object state) Restore ViewScope state.saveState
(FacesContext context) Gets the state of the instance as aSerializable
Object.void
setAfterPhaseListener
(MethodExpression newAfterPhase) Allow an arbitrary method to be called for the "afterPhase" event as the UIViewRoot runs through its lifecycle.void
setBeforePhaseListener
(MethodExpression newBeforePhase) Allow an arbitrary method to be called for the "beforePhase" event as the UIViewRoot runs through its lifecycle.void
setInView
(boolean isInView) Overridden to take no action.void
Set theLocale
to be used in localizing the response being created for this view.void
setRenderKitId
(String renderKitId) Set the render kit identifier of theRenderKit
associated with this view.void
Set the view identifier for this view.void
subscribeToViewEvent
(Class<? extends SystemEvent> systemEvent, SystemEventListener listener) Install the listener instance referenced by argumentlistener
into theUIViewRoot
as a listener for events of typesystemEventClass
.void
unsubscribeFromViewEvent
(Class<? extends SystemEvent> systemEvent, SystemEventListener listener) Remove the listener instance referenced by argumentlistener
from theUIViewRoot
as 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, unsubscribeFromEvent
Methods 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
PhaseListener
s installed on theUIViewRoot
are queued to theExceptionHandler
instead 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
UIViewRoot
instance with default property values.
-
-
Method Details
-
isInView
public boolean isInView()Override superclass method to always return
true
because aUIViewRoot
is defined to always be in a view.- Overrides:
isInView
in classUIComponent
- Returns:
true
if within a view hierarchy,false
otherwise.- Since:
- 2.0
-
setInView
public void setInView(boolean isInView) Overridden to take no action.
- Overrides:
setInView
in classUIComponent
- Parameters:
isInView
- ignore the value.- Since:
- 2.0
-
getFamily
Description copied from class:UIComponent
Return the identifier of the component family to which this component belongs. This identifier, in conjunction with the value of the
rendererType
property, may be used to select the appropriateRenderer
for this component instance. Note this method should NOT returnnull
- Specified by:
getFamily
in classUIComponent
- Returns:
- the component family (not null).
- See Also:
-
getRenderKitId
Return the render kit identifier of the
RenderKit
associated 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
RenderKit
associated 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
MethodExpression
that will be invoked before this view is rendered.- Returns:
- the
MethodExpression
that 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 receivingPhaseEvent
s for a given phase.The method must conform to the signature of
PhaseListener.beforePhase(jakarta.faces.event.PhaseEvent)
.- Parameters:
newBeforePhase
- theMethodExpression
that will be invoked before this view is rendered.- Since:
- 1.2
-
getAfterPhaseListener
Return the
MethodExpression
that will be invoked after this view is rendered.- Returns:
- the
MethodExpression
that 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 receivingPhaseEvent
s for a given phase.The method must conform to the signature of
PhaseListener.afterPhase(jakarta.faces.event.PhaseEvent)
.- Parameters:
newAfterPhase
- theMethodExpression
that will be invoked after this view is rendered.- Since:
- 1.2
-
removePhaseListener
If the argument
toRemove
is in the list ofPhaseListener
s for this instance, it must be removed.- Parameters:
toRemove
- thePhaseListener
to remove.- Since:
- 1.2
-
addPhaseListener
Add the argument
newPhaseListener
to the list ofPhaseListener
s on thisUIViewRoot
.- Parameters:
newPhaseListener
- thePhaseListener
to add- Since:
- 1.2
-
getPhaseListeners
Return an unmodifiable list of the
PhaseListener
instances attached to thisUIViewRoot
instance.- 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
-FacesContext
for the current requestcomponentResource
- TheUIComponent
representing aResource
instance
- 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
component
must be added using the following algorithm:-
If the
target
argument isnull
, look for atarget
attribute on thecomponent
. If there is notarget
attribute, settarget
to 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
componentResource
matches the the ID of a resource that has allready been added, remove the old resource. -
Add the
component
resource to the list.
The resource
Renderer
must ensure of the following:- Do not render when
ResourceHandler.isResourceRendered(FacesContext, String, String)
returnstrue
. - After rendering, call
ResourceHandler.markResourceRendered(FacesContext, String, String)
.
- Parameters:
context
-FacesContext
for the current requestcomponentResource
- TheUIComponent
representing aResource
instancetarget
- The name of the facet for which theUIComponent
will be added- Since:
- 2.0
-
-
getComponentResources
Return an unmodifiable
List
ofUIComponent
s for the providedtarget
agrument. Eachcomponent
in theList
is assumed to represent a resource instance.The default implementation must use an algorithm equivalent to the the following.
- Locate the facet for the
component
by callinggetFacet()
usingtarget
as 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 extendsUIPanel
and overrides theencodeAll()
method to take no action. This is necessary to prevent component resources from being inadvertently rendered.- Set the
id
of the facet to be a string created by prepending the literal string “jakarta_faces_location_
” (without the quotes) to the value of thetarget
argument - Add the facet to the facets
Map
usingtarget
as 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
List
ofUIComponent
children of the facet with the nametarget
. If no children are found for the facet, returnCollections.emptyList()
. - Throws:
NullPointerException
- iftarget
orcontext
isnull
- Since:
- 2.0
- Locate the facet for the
-
getComponentResources
Return an unmodifiable ordered
List
of allUIComponent
resources of all supported targets. Eachcomponent
in theList
is 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
List
of allUIComponent
resources of all supported targets. If no resources are found, return an emptyList
. - Throws:
NullPointerException
- Ifcontext
isnull
.- Since:
- 2.3
-
removeComponentResource
Remove argument
component
, which is assumed to represent a resource instance, as a resource to this view.- Parameters:
context
-FacesContext
for the current requestcomponentResource
- TheUIComponent
representing aResource
instance
- 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
component
must be removed using the following algorithm:- If the
target
argument isnull
, look for atarget
attribute on thecomponent
.
If there is notarget
attribute, settarget
to be the default valuehead
- Call
getComponentResources(jakarta.faces.context.FacesContext, java.lang.String)
to obtain the child list for the given target. - Remove the
component
resource from the child list.
- Parameters:
context
-FacesContext
for the current requestcomponentResource
- TheUIComponent
representing aResource
instancetarget
- The name of the facet for which theUIComponent
will 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:
queueEvent
in classUIComponentBase
- Parameters:
event
-FacesEvent
to be queued- Throws:
IllegalStateException
- if this component is not a descendant of aUIViewRoot
NullPointerException
- ifevent
isnull
-
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
-FacesContext
for the current requestphaseId
-PhaseId
of the current phase- Since:
- 2.0
-
processRestoreState
The default implementation must call
UIComponentBase.processRestoreState(jakarta.faces.context.FacesContext, java.lang.Object)
from within atry
block. Thetry
block must have afinally
block that ensures that noFacesEvent
s remain in the event queue.- Overrides:
processRestoreState
in classUIComponentBase
- Parameters:
context
- theFacesContext
for this requetsstate
- the opaque state object obtained from theStateManager
-
processEvent
If the argument
event
is an instance ofPostRestoreStateEvent
andPartialViewContext.isPartialRequest()
returnstrue
, then loop over all component resources and callResourceHandler.markResourceRendered(FacesContext, String, String)
for each of them. Finally, delegate to super.- Specified by:
processEvent
in interfaceComponentSystemEventListener
- Overrides:
processEvent
in classUIComponent
- Parameters:
event
- theComponentSystemEvent
instance 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_VALUES
if:PartialViewContext.isPartialRequest()
returnstrue
and 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()
returnstrue
and 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:
processDecodes
in classUIComponentBase
- Parameters:
context
-FacesContext
for the request we are processing- Throws:
NullPointerException
- ifcontext
isnull
-
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
- theFacesContext
for 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 aPhaseEvent
for thePhaseId.RENDER_RESPONSE
phase. 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
. AnyException
s that occur during invocation of any of the beforePhase listeners must be logged and swallowed, unless theVIEWROOT_PHASE_LISTENER_QUEUES_EXCEPTIONS_PARAM_NAME
parameter is set. In that case, theException
must be passed to theExceptionHandler
as well.- Overrides:
encodeBegin
in classUIComponentBase
- Parameters:
context
-FacesContext
for 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
UIViewRoot
is 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_PARAM
ResponseStateManager.CLIENT_WINDOW_PARAM
ResponseStateManager.RENDER_KIT_ID_PARAM
ClientBehaviorContext.BEHAVIOR_SOURCE_PARAM_NAME
ClientBehaviorContext.BEHAVIOR_EVENT_PARAM_NAME
PartialViewContext.PARTIAL_EVENT_PARAM_NAME
PartialViewContext.PARTIAL_EXECUTE_PARAM_NAME
PartialViewContext.PARTIAL_RENDER_PARAM_NAME
PartialViewContext.RESET_VALUES_PARAM_NAME
- Overrides:
encodeChildren
in classUIComponentBase
- Parameters:
context
-FacesContext
for 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 aPhaseEvent
for thePhaseId.RENDER_RESPONSE
phase. AnyException
s that occur during invocation of the afterPhase listener must be logged and swallowed, unless theVIEWROOT_PHASE_LISTENER_QUEUES_EXCEPTIONS_PARAM_NAME
parameter is set. In that case, theException
must be passed to theExceptionHandler
as well.. If the current view has view parameters, as indicated by a non-empty and non-UnsupportedOperationException
throwing return fromViewDeclarationLanguage.getViewMetadata(jakarta.faces.context.FacesContext, String)
, callUIViewParameter.encodeAll(jakarta.faces.context.FacesContext)
on each parameter. If callinggetViewParameters()
causesUnsupportedOperationException
to be thrown, the exception must be silently swallowed.- Overrides:
encodeEnd
in classUIComponentBase
- Parameters:
context
-FacesContext
for the response we are creating- Throws:
IOException
- if an input/output error occurs while rendering
-
getRendersChildren
public boolean getRendersChildren()Call
UIComponentBase.getRendersChildren()
IfPartialViewContext.isAjaxRequest()
returnstrue
this method must returntrue
.- Overrides:
getRendersChildren
in classUIComponentBase
- Returns:
true
if the component renders its children,false
otherwise.- Since:
- 2.0
-
processValidators
Perform partial processing by calling
PartialViewContext.processPartial(jakarta.faces.event.PhaseId)
withPhaseId.PROCESS_VALIDATIONS
if:PartialViewContext.isPartialRequest()
returnstrue
and 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()
returnstrue
and 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:
processValidators
in classUIComponentBase
- Parameters:
context
-FacesContext
for the request we are processing- Throws:
NullPointerException
- ifcontext
isnull
- See Also:
-
processUpdates
Perform partial processing by calling
PartialViewContext.processPartial(jakarta.faces.event.PhaseId)
withPhaseId.UPDATE_MODEL_VALUES
if:PartialViewContext.isPartialRequest()
returnstrue
and 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()
returnstrue
and we have a request to process all components in the view (PartialViewContext.isExecuteAll()
returnstrue
)PartialViewContext.isPartialRequest()
returnsfalse
Override the default
UIComponentBase
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:
processUpdates
in classUIComponentBase
- Parameters:
context
-FacesContext
for the request we are processing- Throws:
NullPointerException
- ifcontext
isnull
-
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
-FacesContext
for the request we are processing- Throws:
NullPointerException
- ifcontext
isnull
-
createUniqueId
Generate an identifier for a component. The identifier will be prefixed with UNIQUE_ID_PREFIX, and will be unique within the non-
NamingContainer
child 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:
createUniqueId
in 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
Locale
to be used in localizing the response being created for this view.Algorithm:
If we have a
locale
ivar, 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.Locale
return it. If the value is a String, convert it to ajava.util.Locale
and return it. If there is no value expression for "locale", return the result of callingViewHandler.calculateLocale(jakarta.faces.context.FacesContext)
.- Returns:
- The current
Locale
obtained by executing the above algorithm.
-
setLocale
Set the
Locale
to 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)
, passingtrue
as the argument, and returns the result.- Returns:
- the view map, or
null
. - Since:
- 2.0
-
getViewMap
Returns a
Map
that acts as the interface to the data store that is the "view scope", or, if this instance does not have such aMap
and thecreate
argument istrue
, creates one and returns it. This map must be instantiated lazily and cached for return from subsequent calls to this method on thisUIViewRoot
instance.Application.publishEvent(jakarta.faces.context.FacesContext, java.lang.Class<? extends jakarta.faces.event.SystemEvent>, java.lang.Object)
must be called, passing the currentFacesContext
as the first argument,PostConstructViewMapEvent
.class
as the second argument,UIViewRoot.class
as the third argument and thisUIViewRoot
instance as the fourth argument. It is necessary to pass theUIViewRoot.class
argument to account for cases when theUIViewRoot
has been extended with a custom class.The returned
Map
must be implemented such that callingclear()
on theMap
causesApplication.publishEvent(jakarta.faces.context.FacesContext, java.lang.Class<? extends jakarta.faces.event.SystemEvent>, java.lang.Object)
to be called, passingPreDestroyViewMapEvent
.class
as the first argument and thisUIViewRoot
instance 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, atrue
value for thecreate
argument 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
-true
to create a newMap
for this instance if necessary;false
to returnnull
if 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
listener
into theUIViewRoot
as a listener for events of typesystemEventClass
.Note that installed listeners are not maintained as part of the
UIViewRoot
's state.- Parameters:
systemEvent
- theClass
of event for whichlistener
must be fired.listener
- the implementation ofSystemEventListener
whoseSystemEventListener.processEvent(jakarta.faces.event.SystemEvent)
method must be called when events of typesystemEventClass
are fired.- Throws:
NullPointerException
- ifsystemEventClass
orlistener
arenull
.- Since:
- 2.0
-
unsubscribeFromViewEvent
public void unsubscribeFromViewEvent(Class<? extends SystemEvent> systemEvent, SystemEventListener listener) Remove the listener instance referenced by argument
listener
from theUIViewRoot
as a listener for events of typesystemEventClass
.- Parameters:
systemEvent
- theClass
of event for whichlistener
must be fired.listener
- the implementation ofSystemEventListener
whoseSystemEventListener.processEvent(jakarta.faces.event.SystemEvent)
method must be called when events of typesystemEventClass
are fired.- Throws:
NullPointerException
- ifsystemEventClass
orlistener
arenull
.- Since:
- 2.0
-
getViewListenersForEventClass
public List<SystemEventListener> getViewListenersForEventClass(Class<? extends SystemEvent> systemEvent) Return the
SystemEventListener
instances registered on thisUIComponent
instance that are interested in events of typeeventClass
.- Parameters:
systemEvent
- theClass
of event for which the listeners must be returned.- Returns:
- Collection of view listeners.
- Throws:
NullPointerException
- if argumentsystemEvent
isnull
.- 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:StateHolder
Gets the state of the instance as a
Serializable
Object.If the class that implements this interface has references to instances that implement StateHolder (such as a
UIComponent
with 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 theStateManager
This method must not alter the state of the implementing object. In other words, after executing this code:
Object state = component.saveState(facesContext);
component
should be the same as before executing it.The return from this method must be
Serializable
- Specified by:
saveState
in interfaceStateHolder
- Overrides:
saveState
in classUIComponentBase
- Parameters:
context
- the Faces context.- Returns:
- the saved state.
-
restoreState
Description copied from interface:StateHolder
Perform 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
UIComponent
with 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
state
argument isnull
, take no action and return.- Specified by:
restoreState
in interfaceStateHolder
- Overrides:
restoreState
in classUIComponentBase
- Parameters:
context
- the Faces context.state
- the state.
-