public class UIViewRoot extends UIComponentBase implements UniqueIdVendor
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(javax.faces.context.FacesContext)
and encodeEnd(javax.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 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.
Modifier and Type | Field and Description |
---|---|
static String |
COMPONENT_FAMILY
The standard component family for this component.
|
static String |
COMPONENT_TYPE
The standard component type for this component.
|
static String |
METADATA_FACET_NAME |
static String |
UNIQUE_ID_PREFIX
The prefix that will be used for identifiers generated
by the
createUniqueId() method. |
static String |
VIEW_PARAMETERS_KEY
The key in the value set of the
view metadata BeanDescriptor, the value of which is a
|
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 and Description |
---|
UIViewRoot()
Create a new
UIViewRoot instance with default property
values. |
Modifier and Type | Method and Description |
---|---|
void |
addComponentResource(FacesContext context,
UIComponent componentResource)
Add argument |
void |
addComponentResource(FacesContext context,
UIComponent componentResource,
String target)
Add argument |
void |
addPhaseListener(PhaseListener newPhaseListener)
|
void |
broadcastEvents(FacesContext context,
PhaseId phaseId)
Broadcast any events that have been queued. |
String |
createUniqueId()
Generate an
identifier for a component.
|
String |
createUniqueId(FacesContext context,
String seed)
Generate an identifier for a component.
|
void |
encodeBegin(FacesContext context)
Override the default
UIComponentBase.encodeBegin(javax.faces.context.FacesContext) behavior. |
void |
encodeChildren(FacesContext context)
If |
void |
encodeEnd(FacesContext context)
If |
MethodExpression |
getAfterPhaseListener()
Return the
MethodExpression that will be invoked after
this view is rendered. |
MethodExpression |
getBeforePhaseListener()
Return the
MethodExpression that will be invoked
before this view is rendered. |
List<UIComponent> |
getComponentResources(FacesContext context,
String target)
Return an unmodifiable
|
String |
getFamily()
Return the identifier of the component family to which this
component belongs.
|
Locale |
getLocale()
Return the
Locale to be used in localizing the
response being created for this view. |
List<PhaseListener> |
getPhaseListeners()
Return an unmodifiable list of the
|
String |
getRenderKitId()
Return the render kit identifier of the
RenderKit associated with this view. |
boolean |
getRendersChildren()
Call |
String |
getViewId()
Return the view identifier for this view.
|
List<SystemEventListener> |
getViewListenersForEventClass(Class<? extends SystemEvent> systemEvent)
Return the
|
Map<String,Object> |
getViewMap()
This implementation simply calls through to |
Map<String,Object> |
getViewMap(boolean create)
Returns
a |
boolean |
isInView()
Override superclass method to always return
|
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 caused
FacesContext.renderResponse() or
FacesContext.responseComplete() to be called. |
void |
processDecodes(FacesContext context)
|
void |
processRestoreState(FacesContext context,
Object state)
The default
implementation must call |
void |
processUpdates(FacesContext context)
|
void |
processValidators(FacesContext context)
|
void |
queueEvent(FacesEvent event)
Override the default
UIComponentBase.queueEvent(javax.faces.event.FacesEvent) behavior to
accumulate the queued events for later broadcasting. |
void |
removeComponentResource(FacesContext context,
UIComponent componentResource)
Remove argument |
void |
removeComponentResource(FacesContext context,
UIComponent componentResource,
String target)
Remove argument |
void |
removePhaseListener(PhaseListener toRemove)
If the argument
toRemove is in the list of PhaseListener 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 of |
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. |
Object |
saveState(FacesContext context)
Gets the state of the instance as a
Serializable 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 |
setLocale(Locale locale)
Set the
Locale to be used in localizing the
response being created for this view. |
void |
setRenderKitId(String renderKitId)
Set the render kit identifier of the
RenderKit
associated with this view. |
void |
setViewId(String viewId)
Set the view identifier for this view.
|
void |
subscribeToViewEvent(Class<? extends SystemEvent> systemEvent,
SystemEventListener listener)
Install the listener instance
referenced by argument |
void |
unsubscribeFromViewEvent(Class<? extends SystemEvent> systemEvent,
SystemEventListener listener)
Remove the listener instance
referenced by argument |
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
encodeAll, getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, restoreTransientState, saveTransientState, setValueExpression, visitTree
public static final String METADATA_FACET_NAME
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
>
public static final String COMPONENT_TYPE
The standard component type for this component.
public static final String COMPONENT_FAMILY
The standard component family for this component.
public static final String UNIQUE_ID_PREFIX
The prefix that will be used for identifiers generated
by the createUniqueId()
method.
public UIViewRoot()
Create a new UIViewRoot
instance with default property
values.
public boolean isInView()
Override superclass method to always return
true
because a UIViewRoot
is
defined to always be in a view.
isInView
in class UIComponent
public void setInView(boolean isInView)
Overridden to take no action.
setInView
in class UIComponent
isInView
- public String getFamily()
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 appropriate Renderer
for this component instance.
getFamily
in class UIComponent
UIComponent.getFamily()
public String getRenderKitId()
Return the render kit identifier of the RenderKit
associated with this view. Unless
explicitly set, as in ViewHandler.createView(javax.faces.context.FacesContext, java.lang.String)
, the returned
value will be null.
public void setRenderKitId(String renderKitId)
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.
public String getViewId()
Return the view identifier for this view.
public void setViewId(String viewId)
Set the view identifier for this view.
viewId
- The new view identifierpublic MethodExpression getBeforePhaseListener()
Return the MethodExpression
that will be invoked
before this view is rendered.
MethodExpression
that will be invoked before
this view is rendered.public void setBeforePhaseListener(MethodExpression newBeforePhase)
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 true PhaseListener
, this
approach doesn't allow for only receiving PhaseEvent
s for
a given phase.
The method must conform to the signature of PhaseListener.beforePhase(javax.faces.event.PhaseEvent)
.
newBeforePhase
- the MethodExpression
that will be
invoked before this view is rendered.public MethodExpression getAfterPhaseListener()
Return the MethodExpression
that will be invoked after
this view is rendered.
MethodExpression
that will be invoked after
this view is rendered.public void setAfterPhaseListener(MethodExpression newAfterPhase)
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 true PhaseListener
, this approach doesn't allow for only receiving
PhaseEvent
s for a given phase.
The method
must conform to the signature of PhaseListener.afterPhase(javax.faces.event.PhaseEvent)
.
newAfterPhase
- the MethodExpression
that will be
invoked after this view is rendered.public void removePhaseListener(PhaseListener toRemove)
If the argument toRemove
is in the list of PhaseListener
s for this instance, it must be removed.
toRemove
- the PhaseListener
to remove.public void addPhaseListener(PhaseListener newPhaseListener)
Add the argument newPhaseListener
to the list of
PhaseListener
s on this UIViewRoot
.
newPhaseListener
- the PhaseListener
to addpublic List<PhaseListener> getPhaseListeners()
Return an unmodifiable list of the
PhaseListener
instances attached to this
UIViewRoot
instance.
public void addComponentResource(FacesContext context, UIComponent componentResource)
Add argument component
,
which is assumed to represent a resource instance, as a resource
to this view. A resource instance is rendered by a resource
Renderer
, as described in the Standard HTML
RenderKit. The default implementation must call through to
addComponentResource(javax.faces.context.FacesContext,
javax.faces.component.UIComponent, java.lang.String)
.
context
- FacesContext
for the current requestcomponentResource
- The UIComponent
representing a
Resource
instancepublic 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 resource
Renderer
, as described in the Standard HTML
RenderKit.
The component
must be added using the following
algorithm:
If the target
argument is null
,
look for a target
attribute on the
component
. If there is no target
attribute, set target
to be the default value
head
Call getComponentResources(javax.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.
context
- FacesContext
for the current requestcomponentResource
- The UIComponent
representing a
Resource
instancetarget
- The name of the facet for which the UIComponent
will be addedpublic List<UIComponent> getComponentResources(FacesContext context, String target)
Return an unmodifiable
List
of UIComponent
s for the provided
target
agrument. Each component
in the
List
is assumed to represent a resource
instance.
The default implementation must use an algorithm equivalent to the the following.
component
by calling getFacet()
using
target
as the argument.context.getApplication().createComponent().
The argument to this method
must refer to a component that extends UIPanel
and
overrides the encodeAll()
method to take no action.
This is necessary to prevent component resources from being
inadvertently rendered.id
of the
facet to be a string created by prepending the literal string
“javax_faces_location_
” (without the
quotes) to the value of the target
argumentMap
using target
as the keytarget
- The name of the facet for which the components will be returned.List
of UIComponent
children of
the facet with the name target
. If no children are
found for the facet, return Collections.emptyList()
.NullPointerException
- if target
or
context
is null
public void removeComponentResource(FacesContext context, UIComponent componentResource)
Remove argument component
,
which is assumed to represent a resource instance, as a resource
to this view.
context
- FacesContext
for the current requestcomponentResource
- The UIComponent
representing a
Resource
instancepublic 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 resource
Renderer
, as described in the Standard HTML
RenderKit.
The component
must be removed using the following algorithm:
target
argument is null
, look for a target
attribute on the component
.target
attribute, set target
to be the default value head
getComponentResources(javax.faces.context.FacesContext, java.lang.String)
to obtain the child list for the
given target.component
resource from the child list.context
- FacesContext
for the current requestcomponentResource
- The UIComponent
representing a
Resource
instancetarget
- The name of the facet for which the UIComponent
will be addedpublic void queueEvent(FacesEvent event)
Override the default UIComponentBase.queueEvent(javax.faces.event.FacesEvent)
behavior to
accumulate the queued events for later broadcasting.
queueEvent
in class UIComponentBase
event
- FacesEvent
to be queuedIllegalStateException
- if this component is not a
descendant of a UIViewRoot
NullPointerException
- if event
is null
public void broadcastEvents(FacesContext context, PhaseId phaseId)
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, and UIComponent.popComponentFromEL(javax.faces.context.FacesContext)
must be
called after the return from the broadcast, even in the case of
an exception.
context
- FacesContext
for the current requestphaseId
- PhaseId
of the current phasepublic void processRestoreState(FacesContext context, Object state)
The default
implementation must call UIComponentBase.processRestoreState(javax.faces.context.FacesContext, java.lang.Object)
from within a
try
block. The try
block must have a
finally
block that ensures that no FacesEvent
s remain in the event queue.
processRestoreState
in class UIComponentBase
context
- the FacesContext
for this requetsstate
- the opaque state object obtained from the StateManager
public void processDecodes(FacesContext context)
Perform partial processing by calling
PartialViewContext.processPartial(javax.faces.event.PhaseId)
with
PhaseId.APPLY_REQUEST_VALUES
if:
PartialViewContext.isPartialRequest()
returns true
and we don't have a request to process all
components in the view
(PartialViewContext.isExecuteAll()
returns
false
)UIComponentBase.processDecodes(javax.faces.context.FacesContext)
if one of the following
conditions are met:
PartialViewContext.isPartialRequest()
returns true
and we have a request to process all
components in the view
(PartialViewContext.isExecuteAll()
returns
true
)PartialViewContext.isPartialRequest()
returns false
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 caused FacesContext.renderResponse()
or FacesContext.responseComplete()
to be called.
processDecodes
in class UIComponentBase
context
- FacesContext
for the request we are processingNullPointerException
- if context
is null
public void resetValues(FacesContext context, Collection<String> clientIds)
Visit the clientIds and, if the component is
an instance of EditableValueHolder
,
call its EditableValueHolder.resetValue()
method.
Use UIComponent.visitTree(javax.faces.component.visit.VisitContext, javax.faces.component.visit.VisitCallback)
to do the visiting.
context
- the FacesContext
for the request we are processing.clientIds
- The client ids to be visited, on which the described action will be taken.public void encodeBegin(FacesContext context) throws IOException
Override the default
UIComponentBase.encodeBegin(javax.faces.context.FacesContext)
behavior. If
getBeforePhaseListener()
returns non-null
,
invoke it, passing a PhaseEvent
for the PhaseId.RENDER_RESPONSE
phase. If the internal list populated
by calls to addPhaseListener(javax.faces.event.PhaseListener)
is non-empty, any listeners
in that list must have their PhaseListener.beforePhase(javax.faces.event.PhaseEvent)
method called, passing the PhaseEvent
. 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.
encodeBegin
in class UIComponentBase
context
- FacesContext
for the response we are creatingIOException
- if an input/output error occurs while renderingpublic void encodeChildren(FacesContext context) throws IOException
If PartialViewContext.isAjaxRequest()
returns
true
, perform partial rendering by calling
PartialViewContext.processPartial(javax.faces.event.PhaseId)
with
PhaseId.RENDER_RESPONSE
. If PartialViewContext.isAjaxRequest()
returns
false
, delegate to the parent UIComponentBase.encodeChildren(javax.faces.context.FacesContext)
method.
encodeChildren
in class UIComponentBase
context
- FacesContext
for the response we are creatingIOException
- if an input/output error occurs while renderingpublic void encodeEnd(FacesContext context) throws IOException
If getAfterPhaseListener()
returns non-null
, invoke it, passing a PhaseEvent
for the PhaseId.RENDER_RESPONSE
phase. 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-UnsupportedOperationException
throwing return
from ViewDeclarationLanguage.getViewMetadata(javax.faces.context.FacesContext, String)
,
call UIViewParameter.encodeAll(javax.faces.context.FacesContext)
on each parameter. If
calling getViewParameters()
causes
UnsupportedOperationException
to be thrown, the
exception must be silently swallowed.
encodeEnd
in class UIComponentBase
context
- FacesContext
for the response we are creatingIOException
- if an input/output error occurs while renderingpublic boolean getRendersChildren()
Call UIComponentBase.getRendersChildren()
If PartialViewContext.isAjaxRequest()
returns true
this method must return true
.
getRendersChildren
in class UIComponentBase
public void processValidators(FacesContext context)
Perform partial processing by calling
PartialViewContext.processPartial(javax.faces.event.PhaseId)
with
PhaseId.PROCESS_VALIDATIONS
if:
PartialViewContext.isPartialRequest()
returns true
and we don't have a request to process all
components in the view
(PartialViewContext.isExecuteAll()
returns
false
)UIComponentBase.processValidators(javax.faces.context.FacesContext)
if one of the following
conditions are met:
PartialViewContext.isPartialRequest()
returns true
and we have a request to process all
components in the view
(PartialViewContext.isExecuteAll()
returns
true
)PartialViewContext.isPartialRequest()
returns false
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 caused FacesContext.renderResponse()
or
FacesContext.responseComplete()
to be called.
processValidators
in class UIComponentBase
context
- FacesContext
for the request we are processingNullPointerException
- if context
is null
public void processUpdates(FacesContext context)
Perform partial processing by calling
PartialViewContext.processPartial(javax.faces.event.PhaseId)
with
PhaseId.UPDATE_MODEL_VALUES
if:
PartialViewContext.isPartialRequest()
returns true
and we don't have a request to process all
components in the view
(PartialViewContext.isExecuteAll()
returns
false
)UIComponentBase.processUpdates(javax.faces.context.FacesContext)
if one of the following
conditions are met:
PartialViewContext.isPartialRequest()
returns true
and we have a request to process all
components in the view
(PartialViewContext.isExecuteAll()
returns
true
)PartialViewContext.isPartialRequest()
returns false
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 caused
FacesContext.renderResponse()
or
FacesContext.responseComplete()
to be called.
processUpdates
in class UIComponentBase
context
- FacesContext
for the request we are processingNullPointerException
- if context
is null
public 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 caused FacesContext.renderResponse()
or
FacesContext.responseComplete()
to be called.
context
- FacesContext
for the request we are processingNullPointerException
- if context
is null
public String 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.
public String createUniqueId(FacesContext context, String seed)
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.
createUniqueId
in interface UniqueIdVendor
context
- FacesContextseed
- an optional seed value - e.g. based on the position of the component in the VDL-templatepublic Locale 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 is
null
, return the result of calling ViewHandler.calculateLocale(javax.faces.context.FacesContext)
. If the
value is an instance of java.util.Locale
return it.
If the value is a String, convert it to a
java.util.Locale
and return it. If there is no
value expression for "locale", return the result of calling ViewHandler.calculateLocale(javax.faces.context.FacesContext)
.
Locale
obtained by executing the
above algorithm.public void setLocale(Locale locale)
Set the Locale
to be used in localizing the
response being created for this view.
locale
- The new localization Localepublic Map<String,Object> getViewMap()
This implementation simply calls through to getViewMap(boolean)
, passing true
as the argument, and
returns the result.
public Map<String,Object> getViewMap(boolean 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. This map must be instantiated lazily and cached for return
from subsequent calls to this method on this UIViewRoot
instance. Application.publishEvent(javax.faces.context.FacesContext, java.lang.Class<? extends javax.faces.event.SystemEvent>, java.lang.Object)
must
be called, passing PostConstructViewMapEvent
.class
as the
first argument and this UIViewRoot
instance as the second
argument.
The returned Map
must be implemented such that calling
clear()
on the Map
causes Application.publishEvent(javax.faces.context.FacesContext, java.lang.Class<? extends javax.faces.event.SystemEvent>, java.lang.Object)
to be
called, passing PreDestroyViewMapEvent
.class
as the first argument and this UIViewRoot
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 are
Serializable
.
For reasons made clear in ViewScoped
,
this map must ultimately be stored in the session. For this reason, a
true
value for the create
argument will force the
session to be created with a call to
ExternalContext.getSession(boolean)
.
See FacesContext.setViewRoot(javax.faces.component.UIViewRoot)
for the specification of when the
clear()
method must be called.
create
- true
to create a new Map
for this
instance if necessary; false
to return
null
if there's no current Map
.public void subscribeToViewEvent(Class<? extends SystemEvent> systemEvent, SystemEventListener listener)
Install the listener instance
referenced by argument listener
into the
UIViewRoot
as a listener for events of type
systemEventClass
.
Note that installed listeners are not maintained as part of the
UIViewRoot
's state.
systemEvent
- the Class
of event for which
listener
must be fired.listener
- the implementation of SystemEventListener
whose SystemEventListener.processEvent(javax.faces.event.SystemEvent)
method must
be called when events of type systemEventClass
are
fired.NullPointerException
- if systemEventClass
or listener
are null
.public void unsubscribeFromViewEvent(Class<? extends SystemEvent> systemEvent, SystemEventListener listener)
Remove the listener instance
referenced by argument listener
from the
UIViewRoot
as a listener for events of type
systemEventClass
.
systemEvent
- the Class
of event for which
listener
must be fired.listener
- the implementation of SystemEventListener
whose SystemEventListener.processEvent(javax.faces.event.SystemEvent)
method must
be called when events of type systemEventClass
are
fired.NullPointerException
- if
systemEventClass
or listener
are
null
.public List<SystemEventListener> getViewListenersForEventClass(Class<? extends SystemEvent> systemEvent)
Return the
SystemEventListener
instances registered on this
UIComponent
instance that are interested in events
of type eventClass
.
systemEvent
- the Class
of event for which the
listeners must be returned.NullPointerException
- if argument systemEvent
is null
.public void restoreViewScopeState(FacesContext context, Object state)
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}"/>
.
context
- current FacesContext.state
- the state object.public Object saveState(FacesContext context)
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 the StateHolder.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 the StateManager
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
saveState
in interface StateHolder
saveState
in class UIComponentBase
public void restoreState(FacesContext context, Object state)
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 the StateHolder.restoreState(javax.faces.context.FacesContext, java.lang.Object)
method on all those
instances as well.
If the state
argument is null
, take no action and return.
restoreState
in interface StateHolder
restoreState
in class UIComponentBase
Copyright © 1996-2013, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.