Home » Mojarra-2.0.1 » javax » faces » component » [javadoc | source]
javax.faces.component
public class: UIViewRoot [javadoc | source]
java.lang.Object
   javax.faces.component.UIComponent
      javax.faces.component.UIComponentBase
         javax.faces.component.UIViewRoot

All Implemented Interfaces:
    UniqueIdVendor, PartialStateHolder, ComponentSystemEventListener, SystemEventListenerHolder

UIViewRoot is the UIComponent that represents the root of the UIComponent tree. This component renders markup as the response to Ajax requests. It also serves as the root of the component tree, and as a place to hang per-view PhaseListener s.

For each of the following lifecycle phase methods:

Take the following action regarding PhaseListeners.

Nested Class Summary:
enum class  UIViewRoot.PropertyKeys   
Field Summary
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 >.

    since: 2.0 -
 
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. 

 Map<SystemEventListener> viewListeners     
Fields inherited from javax.faces.component.UIComponent:
CURRENT_COMPONENT,  CURRENT_COMPOSITE_COMPONENT,  BEANINFO_KEY,  FACETS_KEY,  VIEW_LOCATION_KEY,  COMPOSITE_COMPONENT_TYPE_KEY,  COMPOSITE_FACET_NAME,  attributesThatAreSet,  stateHelper,  compositeParent,  bindings,  initialState,  listenersByEventClass
Constructor:
 public UIViewRoot() 
Method from javax.faces.component.UIViewRoot Summary:
addComponentResource,   addComponentResource,   addPhaseListener,   broadcastEvents,   createUniqueId,   createUniqueId,   encodeBegin,   encodeChildren,   encodeEnd,   getAfterPhaseListener,   getBeforePhaseListener,   getComponentResources,   getFamily,   getLocale,   getPhaseListeners,   getRenderKitId,   getRendersChildren,   getViewId,   getViewListenersForEventClass,   getViewMap,   getViewMap,   isInView,   processApplication,   processDecodes,   processRestoreState,   processUpdates,   processValidators,   queueEvent,   removeComponentResource,   removeComponentResource,   removePhaseListener,   restoreState,   saveState,   setAfterPhaseListener,   setBeforePhaseListener,   setInView,   setLocale,   setRenderKitId,   setViewId,   subscribeToViewEvent,   unsubscribeFromViewEvent
Methods from javax.faces.component.UIComponentBase:
addClientBehavior,   addFacesListener,   broadcast,   clearInitialState,   decode,   encodeBegin,   encodeChildren,   encodeEnd,   findComponent,   getAttributes,   getChildCount,   getChildren,   getClientBehaviors,   getClientId,   getDefaultEventName,   getDescriptorMap,   getEventNames,   getFacesContext,   getFacesListeners,   getFacet,   getFacetCount,   getFacets,   getFacetsAndChildren,   getId,   getParent,   getRenderer,   getRendererType,   getRendersChildren,   getValueBinding,   invokeOnComponent,   isRendered,   isTransient,   markInitialState,   processDecodes,   processRestoreState,   processSaveState,   processUpdates,   processValidators,   queueEvent,   removeFacesListener,   restoreAttachedState,   restoreState,   saveAttachedState,   saveState,   setId,   setParent,   setRendered,   setRendererType,   setTransient,   setValueBinding
Methods from javax.faces.component.UIComponent:
addFacesListener,   broadcast,   clearInitialState,   decode,   encodeAll,   encodeBegin,   encodeChildren,   encodeEnd,   findComponent,   getAttributes,   getChildCount,   getChildren,   getClientId,   getClientId,   getCompositeComponentParent,   getContainerClientId,   getCurrentComponent,   getCurrentCompositeComponent,   getFacesContext,   getFacesListeners,   getFacet,   getFacetCount,   getFacets,   getFacetsAndChildren,   getFamily,   getId,   getListenersForEventClass,   getNamingContainer,   getParent,   getRenderer,   getRendererType,   getRendersChildren,   getResourceBundleMap,   getStateHelper,   getStateHelper,   getValueBinding,   getValueExpression,   initialStateMarked,   invokeOnComponent,   isCompositeComponent,   isInView,   isRendered,   isVisitable,   markInitialState,   popComponentFromEL,   processDecodes,   processEvent,   processRestoreState,   processSaveState,   processUpdates,   processValidators,   pushComponentToEL,   queueEvent,   removeFacesListener,   setId,   setInView,   setParent,   setRendered,   setRendererType,   setValueBinding,   setValueExpression,   subscribeToEvent,   unsubscribeFromEvent,   visitTree
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from javax.faces.component.UIViewRoot Detail:
 public  void addComponentResource(FacesContext context,
    UIComponent componentResource) 
 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 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 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.

 public  void addPhaseListener(PhaseListener newPhaseListener) 

    Add the argument newPhaseListener to the list of PhaseListener s on this UIViewRoot.

 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 must be called before the event is broadcast, and UIComponent#popComponentFromEL must be called after the return from the broadcast, even in the case of an exception.

 public String createUniqueId() 

    Generate an identifier for a component. The identifier will be prefixed with UNIQUE_ID_PREFIX, and will be unique within 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.

 public  void encodeBegin(FacesContext context) throws IOException 
 public  void encodeChildren(FacesContext context) throws IOException 
 public  void encodeEnd(FacesContext context) throws IOException 
 public MethodExpression getAfterPhaseListener() 
 public MethodExpression getBeforePhaseListener() 
 public 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.

    • Locate the facet for the component by calling getFacet() using target as the argument.
    • If the facet is not found, create the facet by calling context.getApplication().createComponent() using javax.faces.Panel as the argument
      • Set the id of the facet to be target
      • Add the facet to the facets Map using target as the key
    • return the children of the facet
 public String getFamily() 
 public 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 javax.faces.application.ViewHandler#calculateLocale . 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 javax.faces.application.ViewHandler#calculateLocale .

 public List<PhaseListener> getPhaseListeners() 

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

 public String getRenderKitId() 
 public boolean getRendersChildren() 
 public String getViewId() 

    Return the view identifier for this view.

 public List<SystemEventListener> getViewListenersForEventClass(Class<SystemEvent> systemEvent) 

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

 public 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. javax.faces.application.Application#publishEvent 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 javax.faces.application.Application#publishEvent to be called, passing PreDestroyViewMapEvent .class as the first argument and this UIViewRoot instance as the second argument.

    See FacesContext#setViewRoot for the specification of when the clear() method must be called.

 public boolean isInView() 

    Return trues.

 public  void processApplication(FacesContext context) 
 public  void processDecodes(FacesContext context) 
 public  void processRestoreState(FacesContext context,
    Object state) 
 public  void processUpdates(FacesContext context) 
 public  void processValidators(FacesContext context) 
 public  void queueEvent(FacesEvent event) 
 public  void removeComponentResource(FacesContext context,
    UIComponent componentResource) 

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

 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 resource Renderer, as described in the Standard HTML RenderKit.

    The component must be removed 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 to obtain the child list for the given target.
    • Remove the component resource from the child list.

 public  void removePhaseListener(PhaseListener toRemove) 

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

 public  void restoreState(FacesContext context,
    Object state) 
 public Object saveState(FacesContext context) 
 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 .

 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 .

 public  void setInView(boolean isInView) 

    Overridden to take no action.

 public  void setLocale(Locale locale) 

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

 public  void setRenderKitId(String renderKitId) 

    Set the render kit identifier of the javax.faces.render.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  void setViewId(String viewId) 

    Set the view identifier for this view.

 public  void subscribeToViewEvent(Class<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.

 public  void unsubscribeFromViewEvent(Class<SystemEvent> systemEvent,
    SystemEventListener listener) 

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