Class UIViewAction

  • All Implemented Interfaces:
    ActionSource, ActionSource2, PartialStateHolder, StateHolder, TransientStateHolder, ComponentSystemEventListener, FacesListener, SystemEventListenerHolder, EventListener

    public class UIViewAction
    extends UIComponentBase
    implements ActionSource2

    UIViewAction represents a method invocation that occurs during the request processing lifecycle, usually in response to an initial request, as opposed to a postback.

    The ViewDeclarationLanguage implementation must cause an instance of this component to be placed in the view for each occurrence of an <f:viewAction /> element placed inside of an <f:metadata /> element. The user must place <f:metadata /> as a direct child of the UIViewRoot.

    Because this class implements ActionSource2, any actions that one would normally take on a component that implements ActionSource2, such as UICommand, are valid for instances of this class. Instances of this class participate in the regular Jakarta Faces lifecycle, including on Ajax requests.

    The purpose of this component is to provide a light-weight front-controller solution for executing code upon the loading of a Jakarta Faces view to support the integration of system services, content retrieval, view management, and navigation. This functionality is especially useful for non-faces (initial) requests.

    The most common use case for this component is to take actions necessary for a particular view, often with the help of one or more UIViewParameters.

    The NavigationHandler is consulted after the action is invoked to carry out the navigation case that matches the action signature and outcome. If a navigation case is matched that causes the new viewId to be different from the current viewId, the runtime must force a redirect to that matched navigation case with different viewId, regardless of whether or not the matched navigation case with different viewId called for a redirect. If the navigation will result in a flow transition, the appropriate metadata must be included in the query string for the redirect. See section 7.4.2 "Default NavigationHandler Algorithm" of the Jakarta Faces Specification Document, for the specification of how to handle &lt;redirect /&gt; cases.

    It's important to note that the full component tree is not built before the UIViewAction components are processed on an non-faces (initial) request. Rather, the component tree only contains the ViewMetadata, an important part of the optimization of this component and what sets it apart from a PreRenderViewEvent listener.

    Since:
    2.2
    • Field Detail

      • COMPONENT_TYPE

        public static final String COMPONENT_TYPE

        The standard component type for this component.

        See Also:
        Constant Field Values
      • COMPONENT_FAMILY

        public static final String COMPONENT_FAMILY

        The standard component family for this component.

        See Also:
        Constant Field Values
    • Constructor Detail

      • UIViewAction

        public UIViewAction()

        Create a new UIViewAction instance with default property values.

    • Method Detail

      • getFamily

        public String 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 appropriate Renderer for this component instance. Note this method should NOT return null

        Specified by:
        getFamily in class UIComponent
        Returns:
        the component family (not null).
      • isImmediate

        public boolean isImmediate()

        If the value of the component's immediate attribute is true, the action will be invoked during the Apply Request Values Jakarta Faces lifecycle phase. Otherwise, the action will be invoked during the Invoke Application phase, the default behavior. The phase can be set explicitly in the phase attribute, which takes precedence over the immediate attribute.

        Specified by:
        isImmediate in interface ActionSource
        Returns:
        true if immediate, false otherwise.
        Since:
        2.2
      • setImmediate

        public void setImmediate​(boolean immediate)

        Set the "immediate execution" flag for this UIComponent.

        Specified by:
        setImmediate in interface ActionSource
        Parameters:
        immediate - The new immediate execution flag
        Since:
        2.2
      • getPhase

        public String getPhase()

        Returns the name of the lifecycle phase in which the action is to be queued.

        Returns:
        the phase (as string).
        Since:
        2.2
      • isProcessingBroadcast

        public static boolean isProcessingBroadcast​(FacesContext context)

        Returns true if the current request processing lifecycle is in the midst of processing the broadcast of an event queued during a call to decode(jakarta.faces.context.FacesContext). The implementation of broadcast(jakarta.faces.event.FacesEvent) is responsible for ensuring that calls to this method accurately reflect this fact.

        Parameters:
        context - FacesContext for the current request
        Returns:
        true is currently processing broadcast, false otherwise.
        Since:
        2.2
      • getActionExpression

        public MethodExpression getActionExpression()

        Return the MethodExpression pointing at the application action to be invoked, if this UIComponent is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property.

        Specified by:
        getActionExpression in interface ActionSource2
        Returns:
        the action expression.
        Since:
        2.2
      • setActionExpression

        public void setActionExpression​(MethodExpression actionExpression)

        Set the MethodExpression pointing at the appication action to be invoked, if this UIComponent is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property.

        Any method referenced by such an expression must be public, with a return type of String, and accept no parameters.

        Specified by:
        setActionExpression in interface ActionSource2
        Parameters:
        actionExpression - the action expression.
        Since:
        2.2
      • isOnPostback

        public boolean isOnPostback()

        If true this component will operate on postback.

        Returns:
        true if operating upon postback, false otherwise.
        Since:
        2.2
      • setOnPostback

        public void setOnPostback​(boolean onPostback)

        Controls whether or not this component operates on postback.

        Parameters:
        onPostback - the onPostback flag.
        Since:
        2.2
      • setRendered

        public void setRendered​(boolean condition)

        Sets the if property of this component.

        Overrides:
        setRendered in class UIComponentBase
        Parameters:
        condition - the new value of the property.
        Since:
        2.2