Class UIViewRoot

All Implemented Interfaces:
PartialStateHolder, StateHolder, TransientStateHolder, UniqueIdVendor, ComponentSystemEventListener, FacesListener, SystemEventListenerHolder, EventListener

@JSFComponent(name="f:view") @JSFJspProperty(name="binding", returnType="java.lang.String", tagExcluded=true) public class UIViewRoot extends UIComponentBase implements UniqueIdVendor
Creates a Faces View, which is a container that holds all of the components that are part of the view.

Unless otherwise specified, all attributes accept static values or EL expressions.

See the javadoc for this class in the JSF Specification for further details.

  • Field Details

  • Constructor Details

    • UIViewRoot

      public UIViewRoot()
      Construct an instance of the UIViewRoot.
  • Method Details

    • addComponentResource

      public void addComponentResource(FacesContext context, UIComponent componentResource)
      Since:
      2.0
    • addComponentResource

      public void addComponentResource(FacesContext context, UIComponent componentResource, String target)
      Since:
      2.0
    • addPhaseListener

      public void addPhaseListener(PhaseListener phaseListener)
      Adds a The phaseListeners attached to ViewRoot.
    • broadcastEvents

      public void broadcastEvents(FacesContext context, PhaseId phaseId)
      Since:
      2.0
    • createUniqueId

      public String createUniqueId()
      Provides a unique id for this component instance.
    • createUniqueId

      public String createUniqueId(FacesContext context, String seed)
      Specified by:
      createUniqueId in interface UniqueIdVendor
      Since:
      2.0
    • encodeBegin

      public void encodeBegin(FacesContext context) throws IOException
      Overrides:
      encodeBegin in class UIComponentBase
      Throws:
      IOException
    • encodeChildren

      public void encodeChildren(FacesContext context) throws IOException
      Overrides:
      encodeChildren in class UIComponentBase
      Throws:
      IOException
      Since:
      2.0
    • encodeEnd

      public void encodeEnd(FacesContext context) throws IOException
      Overrides:
      encodeEnd in class UIComponentBase
      Throws:
      IOException
    • getAfterPhaseListener

      @JSFProperty(returnSignature="void", methodSignature="jakarta.faces.event.PhaseEvent", stateHolder=true) public jakarta.el.MethodExpression getAfterPhaseListener()
      MethodExpression pointing to a method that takes a jakarta.faces.event.PhaseEvent and returns void, called after every phase except for restore view.
      Returns:
      the new afterPhaseListener value
    • getBeforePhaseListener

      @JSFProperty(returnSignature="void", methodSignature="jakarta.faces.event.PhaseEvent", stateHolder=true) public jakarta.el.MethodExpression getBeforePhaseListener()
      MethodExpression pointing to a method that takes a jakarta.faces.event.PhaseEvent and returns void, called before every phase except for restore view.
      Returns:
      the new beforePhaseListener value
    • getComponentResources

      public List<UIComponent> getComponentResources(FacesContext context, String target)
      Since:
      2.0
    • getComponentResources

      public List<UIComponent> getComponentResources(FacesContext context)
      Parameters:
      context -
      Returns:
      Since:
      2.3
    • getFamily

      public String getFamily()
      Specified by:
      getFamily in class UIComponent
    • getLocale

      @JSFProperty public Locale getLocale()
      The locale for this view.

      Defaults to the default locale specified in the faces configuration file.

    • getPhaseListeners

      public List<PhaseListener> getPhaseListeners()
      Since:
      2.0
    • getRenderKitId

      @JSFProperty public String getRenderKitId()
      Defines what renderkit should be used to render this view.
    • getRendersChildren

      public boolean getRendersChildren()
      Description copied from class: UIComponentBase
      Indicates whether this component or its renderer manages the invocation of the rendering methods of its child components. When this is true:
      • This component's encodeBegin method will only be called after all the child components have been created and added to this component.
      • This component's encodeChildren method will be called after its encodeBegin method. Components for which this method returns false do not get this method invoked at all.
      • No rendering methods will be called automatically on child components; this component is required to invoke the encodeBegin/encodeEnd/etc on them itself.
      Overrides:
      getRendersChildren in class UIComponentBase
      Since:
      2.0
    • getViewId

      @JSFProperty(tagExcluded=true) public String getViewId()
      A unique identifier for the "template" from which this view was generated.

      Typically this is the filesystem path to the template file, but the exact details are the responsibility of the current ViewHandler implementation.

    • getViewMap

      public Map<String,Object> getViewMap()
      Since:
      2.0
    • getViewMap

      public Map<String,Object> getViewMap(boolean create)
      Since:
      2.0
    • isInView

      public boolean isInView()
      Indicate if this component is inside a view, or in other words is contained by an UIViewRoot instance (which represents the view). If this component is a UIViewRoot instance, the components "always" is on the view. By default it is false but for UIViewRoot instances is true.
      Overrides:
      isInView in class UIComponent
      Returns:
    • processApplication

      public void processApplication(FacesContext context)
    • processDecodes

      public void processDecodes(FacesContext context)
      Overrides:
      processDecodes in class UIComponentBase
    • processRestoreState

      public void processRestoreState(FacesContext context, Object state)
      Overrides:
      processRestoreState in class UIComponentBase
      Since:
      2.0
    • queueEvent

      public void queueEvent(FacesEvent event)
      Overrides:
      queueEvent in class UIComponentBase
    • processValidators

      public void processValidators(FacesContext context)
      Overrides:
      processValidators in class UIComponentBase
    • processUpdates

      public void processUpdates(FacesContext context)
      Description copied from class: UIComponentBase
      This isn't an input component, so just pass on the processUpdates call to child components and facets that might be input components.

      Components that were never rendered can't possibly be receiving update data (no corresponding fields were ever put into the response) so if this component is not rendered then this method does not invoke processUpdates on its children.

      Overrides:
      processUpdates in class UIComponentBase
    • setLocale

      public void setLocale(Locale locale)
    • setRenderKitId

      public void setRenderKitId(String renderKitId)
    • setRendered

      @JSFProperty(tagExcluded=true) public void setRendered(boolean state)
      DO NOT USE.

      This inherited property is disabled. Although this class extends a base-class that defines a read/write rendered property, this particular subclass does not support setting it. Yes, this is broken OO design: direct all complaints to the Faces spec group.

      Overrides:
      setRendered in class UIComponentBase
    • setId

      @JSFProperty(tagExcluded=true) public void setId(String id)
      Description copied from class: UIComponentBase
      Set an identifier for this component which is unique within the scope of the nearest ancestor NamingContainer component. The id is not necessarily unique across all components in the current view.

      The id must start with an underscore if it is generated by the Faces framework, and must not start with an underscore if it has been specified by the user (eg in a JSP tag).

      The first character of the id must be an underscore or letter. Following characters may be letters, digits, underscores or dashes.

      Null is allowed as a parameter, and will reset the id to null.

      The clientId of this component is reset by this method; see getClientId for more info.

      Overrides:
      setId in class UIComponentBase
    • setInView

      public void setInView(boolean isInView)
      Define if the component is on the view or not.

      This value is set in the following conditions:

      • Component / Facet added: if the parent isInView = true, set it to true and all their children or facets, otherwise take no action
      • Component / Facet removed: if the parent isInView = false, set it to false and all their children or facets, otherwise take no action
      Overrides:
      setInView in class UIComponent
    • removeComponentResource

      public void removeComponentResource(FacesContext context, UIComponent componentResource)
    • removeComponentResource

      public void removeComponentResource(FacesContext context, UIComponent componentResource, String target)
    • setViewId

      public void setViewId(String viewId)
    • removePhaseListener

      public void removePhaseListener(PhaseListener phaseListener)
      Removes a The phaseListeners attached to ViewRoot.
    • setBeforePhaseListener

      public void setBeforePhaseListener(jakarta.el.MethodExpression beforePhaseListener)
      Sets
      Parameters:
      beforePhaseListener - the new beforePhaseListener value
    • setAfterPhaseListener

      public void setAfterPhaseListener(jakarta.el.MethodExpression afterPhaseListener)
      Sets
      Parameters:
      afterPhaseListener - the new afterPhaseListener value
    • getAttributes

      public Map<String,Object> getAttributes()
      Description copied from class: UIComponentBase
      Get a map through which all the UIComponent's properties, value-bindings and non-property attributes can be read and written.

      When writing to the returned map:

      • If this component has an explicit property for the specified key then the setter method is called. An IllegalArgumentException is thrown if the property is read-only. If the property is readable then the old value is returned, otherwise null is returned.
      • Otherwise the key/value pair is stored in a map associated with the component.
      Note that value-bindings are not written by put calls to this map. Writing to the attributes map using a key for which a value-binding exists will just store the value in the attributes map rather than evaluating the binding, effectively "hiding" the value-binding from later attributes.get calls. Setter methods on components commonly do not evaluate a binding of the same name; they just store the provided value directly on the component.

      When reading from the returned map:

      • If this component has an explicit property for the specified key then the getter method is called. If the property exists, but is read-only (ie only a setter method is defined) then an IllegalArgumentException is thrown.
      • If the attribute map associated with the component has an entry with the specified key, then that is returned.
      • If this component has a value-binding for the specified key, then the value-binding is evaluated to fetch the value.
      • Otherwise, null is returned.
      Note that components commonly define getter methods such that they evaluate a value-binding of the same name if there isn't yet a local property.

      Assigning values to the map which are not explicit properties on the underlying component can be used to "tunnel" attributes from the JSP tag (or view-specific equivalent) to the associated renderer without modifying the component itself.

      Any value-bindings and non-property attributes stored in this map are automatically serialized along with the component when the view is serialized.

      Overrides:
      getAttributes in class UIComponentBase
    • resetValues

      public void resetValues(FacesContext context, Collection<String> clientIds)
      Parameters:
      context -
      clientIds -
      Since:
      2.2
    • saveState

      public Object saveState(FacesContext facesContext)
      Description copied from class: UIComponentBase
      Invoked after the render phase has completed, this method returns an object which can be passed to the restoreState of some other instance of UIComponentBase to reset that object's state to the same values as this object currently has.
      Specified by:
      saveState in interface StateHolder
      Overrides:
      saveState in class UIComponentBase
    • restoreState

      public void restoreState(FacesContext facesContext, Object state)
      Description copied from class: UIComponentBase
      Invoked in the "restore view" phase, this initialises this object's members from the values saved previously into the provided state object.

      Specified by:
      restoreState in interface StateHolder
      Overrides:
      restoreState in class UIComponentBase
      state - is an object previously returned by the saveState method of this class.
    • restoreViewScopeState

      public void restoreViewScopeState(FacesContext facesContext, Object state)
      Parameters:
      facesContext -
      state -
      Since:
      2.2
    • getViewListenersForEventClass

      public List<SystemEventListener> getViewListenersForEventClass(Class<? extends SystemEvent> systemEvent)
    • subscribeToViewEvent

      public void subscribeToViewEvent(Class<? extends SystemEvent> systemEvent, SystemEventListener listener)
    • unsubscribeFromViewEvent

      public void unsubscribeFromViewEvent(Class<? extends SystemEvent> systemEvent, SystemEventListener listener)
    • getDoctype

      public Doctype getDoctype()

      Return the doctype of this view.

      Returns:
      the doctype of this view.
      Since:
      4.0
    • setDoctype

      public void setDoctype(Doctype doctype)

      Set the doctype of this view.

      Parameters:
      doctype - The doctype.
      Since:
      4.0