Top Description Inners Fields Constructors Methods
jakarta.faces.component

public Class UIViewRoot

extends UIComponentBase
implements UniqueIdVendor
Class Inheritance
All Implemented Interfaces
jakarta.faces.component.UniqueIdVendor
Static Imports
java.util.Collections.unmodifiableList, java.util.logging.Level.SEVERE, .Level.WARNING

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:

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, 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, invoke the afterPhase method on each one whose PhaseListener#getPhaseId matches the current phaseId, passing in the same PhaseId as in the previous step.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
pack-priv static enum
private static class

Field Summary

Modifier and TypeField and Description
private boolean
beforeMethodException

Set and cleared during the lifetime of a lifecycle phase.

public static final String
COMPONENT_FAMILY

The standard component family for this component.

public static final String
COMPONENT_TYPE

The standard component type for this component.

private Doctype
doctype

Set during view build time.

private List<List<FacesEvent>>
events

An array of Lists of events that have been queued for later broadcast, with one List for each lifecycle phase.

private static Lifecycle
private static final Map<String, String>
private static final String
private static final Logger
public static final String
METADATA_FACET_NAME

The key in the facet collection that contains the meta data of the view root.

private ListIterator<PhaseListener>
phaseListenerIterator

Set and cleared during the lifetime of a lifecycle phase.

private boolean
skipPhase

Set and cleared during the lifetime of a lifecycle phase.

public static final String
UNIQUE_ID_PREFIX

The prefix that will be used for identifiers generated by the createUniqueId() method.

private Object[]
public static final String
VIEW_PARAMETERS_KEY

The key in the value set of the view metadata BeanDescriptor, the value of which is a List<UIViewParameter.Reference>.

pack-priv Map<Class<? extends SystemEvent>, List<SystemEventListener>>
public static final String
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 the UIViewRoot are queued to the jakarta.faces.context.ExceptionHandler instead of being logged and swallowed.

Constructor Summary

AccessConstructor and Description
public
UIViewRoot()

Create a new UIViewRoot instance with default property values.

Method Summary

Modifier and TypeMethod and Description
public void
addComponentResource(FacesContext
FacesContext for the current request
context
,
UIComponent componentResource)

Add argument component, which is assumed to represent a resource instance, as a resource to this view.

public void
addComponentResource(FacesContext
FacesContext for the current request
context
,
UIComponent componentResource, String
The name of the facet for which the UIComponent will be added
target
)

Add argument component, which is assumed to represent a resource instance, as a resource to this view.

public void
addPhaseListener(PhaseListener
the PhaseListener to add
newPhaseListener
)

Add the argument newPhaseListener to the list of PhaseListeners on this UIViewRoot.

public void
broadcastEvents(FacesContext
FacesContext for the current request
context
,
PhaseId
PhaseId of the current phase
phaseId
)

Broadcast any events that have been queued.

private void
private static PhaseEvent
public String

Returns:

the identifier.
createUniqueId
()

Generate an identifier for a component.

public String

Returns:

a unique-id in this component-container
createUniqueId
(FacesContext
FacesContext
context
,
String
an optional seed value - e.g. based on the position of the component in the VDL-template
seed
)

Implements jakarta.faces.component.UniqueIdVendor.createUniqueId.

Generate an identifier for a component.

public void
encodeBegin(FacesContext
FacesContext for the response we are creating
context
)

Overrides jakarta.faces.component.UIComponentBase.encodeBegin.

Override the default UIComponentBase#encodeBegin behavior.

public void
public void
encodeEnd(FacesContext
FacesContext for the response we are creating
context
)

Overrides jakarta.faces.component.UIComponentBase.encodeEnd.

If getAfterPhaseListener returns non-null, invoke it, passing a PhaseEvent for the PhaseId#RENDER_RESPONSE phase.

private void
public MethodExpression

Returns:

the MethodExpression that will be invoked after this view is rendered.
getAfterPhaseListener
()

Return the MethodExpression that will be invoked after this view is rendered.

public MethodExpression

Returns:

the MethodExpression that will be invoked before this view is rendered.
getBeforePhaseListener
()

Return the MethodExpression that will be invoked before this view is rendered.

public List<UIComponent>

Returns:

A List of UIComponent children of the facet with the name target. If no children are found for the facet, return Collections.emptyList().
getComponentResources
(FacesContext
the Faces context.
context
,
String
The name of the facet for which the components will be returned.
target
)

Return an unmodifiable List of UIComponents for the provided target agrument.

public List<UIComponent>

Returns:

A List of all UIComponent resources of all supported targets. If no resources are found, return an empty List.
getComponentResources
(FacesContext
The Faces context.
context
)

Return an unmodifiable ordered List of all UIComponent resources of all supported targets.

private List<UIComponent>
getComponentResources(FacesContext context, String target, boolean create)

public Doctype

Returns:

the doctype of this view.
getDoctype
()

Return the doctype of this view.

public String
getFamily()

Implements abstract jakarta.faces.component.UIComponent.getFamily.

Return the identifier of the component family to which this component belongs.

private static String
public Locale

Returns:

The current Locale obtained by executing the above algorithm.
getLocale
()

Return the Locale to be used in localizing the response being created for this view.

private static Locale
public List<PhaseListener>

Returns:

the list of phase listeners.
getPhaseListeners
()

Return an unmodifiable list of the PhaseListener instances attached to this UIViewRoot instance.

public String

Returns:

the render kit id, or null.
getRenderKitId
()

Return the render kit identifier of the jakarta.faces.render.RenderKit associated with this view.

public boolean
public String

Returns:

the view id.
getViewId
()

Return the view identifier for this view.

public List<SystemEventListener>

Returns:

Collection of view listeners.
getViewListenersForEventClass
(Class<? extends SystemEvent>
the Class of event for which the listeners must be returned.
systemEvent
)

Return the SystemEventListener instances registered on this UIComponent instance that are interested in events of type eventClass.

public Map<String, Object>

Returns:

the view map, or null.
getViewMap
()

This implementation simply calls through to getViewMap(boolean), passing true as the argument, and returns the result.

public Map<String, Object>

Returns:

the view map, or null.
getViewMap
(boolean
true to create a new Map for this instance if necessary; false to return null if there's no current Map.
create
)

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 a Map and the create argument is true, creates one and returns it.

private static int

Returns:

starting at fromIndex, the index of the first occurrence of any substring from set in toSearch, or -1 if no such match is found
indexOfSet
(String
local string
str
,
char[]
the substring
set
,
int
starting index
fromIndex
)

private void
public boolean
isInView()

Overrides jakarta.faces.component.UIComponent.isInView.

Override superclass method to always return true because a UIViewRoot is defined to always be in a view.

private void
notifyAfter(FacesContext context, PhaseId phaseId)

private void
notifyBefore(FacesContext context, PhaseId phaseId)

private void
notifyPhaseListeners(FacesContext
the context for this request
context
,
PhaseId
the PhaseId of the current phase
phaseId
,
boolean
if true, notify beforePhase listeners. Notify afterPhase listeners otherwise.
isBefore
)

Utility method that notifies phaseListeners for the given phaseId.

public void
processApplication(FacesContext
FacesContext for the request we are processing
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 caused FacesContext#renderResponse or FacesContext#responseComplete to be called.

public void
processDecodes(FacesContext
FacesContext for the request we are processing
context
)

Overrides jakarta.faces.component.UIComponentBase.processDecodes.

Perform partial processing by calling jakarta.faces.context.PartialViewContext#processPartial with PhaseId#APPLY_REQUEST_VALUES if:

public void
processEvent(ComponentSystemEvent
the ComponentSystemEvent instance that is being processed.
event
)

Overrides jakarta.faces.component.UIComponent.processEvent.

Implements jakarta.faces.event.ComponentSystemEventListener.processEvent.

If the argument event is an instance of PostRestoreStateEvent and PartialViewContext#isPartialRequest() returns true, then loop over all component resources and call ResourceHandler#markResourceRendered(FacesContext, String, String) for each of them.

public void
processRestoreState(FacesContext
the FacesContext for this requets
context
,
Object
the opaque state object obtained from the jakarta.faces.application.StateManager
state
)

Overrides jakarta.faces.component.UIComponentBase.processRestoreState.

The default implementation must call UIComponentBase#processRestoreState from within a try block.

public void
processUpdates(FacesContext
FacesContext for the request we are processing
context
)

Overrides jakarta.faces.component.UIComponentBase.processUpdates.

Perform partial processing by calling jakarta.faces.context.PartialViewContext#processPartial with PhaseId#UPDATE_MODEL_VALUES if:

public void
processValidators(FacesContext
FacesContext for the request we are processing
context
)

Overrides jakarta.faces.component.UIComponentBase.processValidators.

Perform partial processing by calling jakarta.faces.context.PartialViewContext#processPartial with PhaseId#PROCESS_VALIDATIONS if:

public void
queueEvent(FacesEvent
FacesEvent to be queued
event
)

Overrides jakarta.faces.component.UIComponentBase.queueEvent.

Override the default UIComponentBase#queueEvent behavior to accumulate the queued events for later broadcasting.

public void
removeComponentResource(FacesContext
FacesContext for the current request
context
,
UIComponent componentResource)

Remove argument component, which is assumed to represent a resource instance, as a resource to this view.

public void
removeComponentResource(FacesContext
FacesContext for the current request
context
,
UIComponent componentResource, String
The name of the facet for which the UIComponent will be added
target
)

Remove argument component, which is assumed to represent a resource instance, as a resource to this view.

public void
removePhaseListener(PhaseListener
the PhaseListener to remove.
toRemove
)

If the argument toRemove is in the list of PhaseListeners for this instance, it must be removed.

public void
resetValues(FacesContext
the FacesContext for the request we are processing.
context
,
Collection<String>
The client ids to be visited, on which the described action will be taken.
clientIds
)

Visit the clientIds and, if the component is an instance of EditableValueHolder, call its EditableValueHolder#resetValue method.

public void
restoreState(FacesContext
the Faces context.
context
,
Object
the state.
state
)

Overrides jakarta.faces.component.UIComponentBase.restoreState.

Implements jakarta.faces.component.StateHolder.restoreState.

Perform any processing required to restore the state from the entries in the state Object.

public void
restoreViewScopeState(FacesContext
current FacesContext.
context
,
Object
the state object.
state
)

Restore ViewScope state.

public Object
saveState(FacesContext
the Faces context.
context
)

Overrides jakarta.faces.component.UIComponentBase.saveState.

Implements jakarta.faces.component.StateHolder.saveState.

Gets the state of the instance as a Serializable Object.

public void
setAfterPhaseListener(MethodExpression
the MethodExpression that will be invoked after this view is rendered.
newAfterPhase
)

Allow an arbitrary method to be called for the "afterPhase" event as the UIViewRoot runs through its lifecycle.

public void
setBeforePhaseListener(MethodExpression
the MethodExpression that will be invoked before this view is rendered.
newBeforePhase
)

Allow an arbitrary method to be called for the "beforePhase" event as the UIViewRoot runs through its lifecycle.

public void
setDoctype(Doctype
The doctype.
doctype
)

Set the doctype of this view.

public void
setInView(boolean
ignore the value.
isInView
)

Overrides jakarta.faces.component.UIComponent.setInView.

Overridden to take no action.

public void
setLocale(Locale
The new localization Locale
locale
)

Set the Locale to be used in localizing the response being created for this view.

public void
setRenderKitId(String
The new jakarta.faces.render.RenderKit identifier, or null to disassociate this view with any specific jakarta.faces.render.RenderKit instance
renderKitId
)

Set the render kit identifier of the jakarta.faces.render.RenderKit associated with this view.

public void
setViewId(String
The new view identifier
viewId
)

Set the view identifier for this view.

public void
subscribeToViewEvent(Class<? extends SystemEvent>
the Class of event for which listener must be fired.
systemEvent
,
SystemEventListener
the implementation of jakarta.faces.event.SystemEventListener whose jakarta.faces.event.SystemEventListener#processEvent method must be called when events of type systemEventClass are fired.
listener
)

Install the listener instance referenced by argument listener into the UIViewRoot as a listener for events of type systemEventClass.

public void
unsubscribeFromViewEvent(Class<? extends SystemEvent>
the Class of event for which listener must be fired.
systemEvent
,
SystemEventListener
the implementation of jakarta.faces.event.SystemEventListener whose jakarta.faces.event.SystemEventListener#processEvent method must be called when events of type systemEventClass are fired.
listener
)

Remove the listener instance referenced by argument listener from the UIViewRoot as a listener for events of type systemEventClass.

Inherited from jakarta.faces.component.UIComponentBase:
addClientBehavioraddFacesListenerbroadcastclearInitialStatedecodefindComponentgetAttributesgetChildCountgetChildrengetClientBehaviorsgetClientIdgetDefaultEventNamegetDescriptorMapgetEventNamesgetFacesContextgetFacesListenersgetFacetgetFacetCountgetFacetsgetFacetsAndChildrengetIdgetListenersForEventClassgetParentgetPassThroughAttributesgetRenderergetRendererTypeinvokeOnComponentisRenderedisTransientmarkInitialStateprocessSaveStateremoveFacesListenerrestoreAttachedStatesaveAttachedStatesetIdsetParentsetRenderedsetRendererTypesetTransientsubscribeToEventunsubscribeFromEvent