Class Components


  • public final class Components
    extends Object

    Collection of utility methods for the Faces API with respect to working with UIComponent. There are several traversal/lookup methods, there are several UIForm and UIInput related methods which makes it easier to deal with forms and inputs.

    Usage

    Here are some examples:

     // Get closest parent of given type.
     UIForm form = Components.getClosestParent(someUIInputComponent, UIForm.class);
     
     // Get currently submitted form.
     UIForm form = Components.getCurrentForm();
     
     // Get currently invoked command, useful for logging actions in a phase listener.
     UICommand command = Components.getCurrentCommand();
     
     // Get the label of the given UIInput component as Faces uses for validation messages.
     String label = Components.getLabel(someUIInputComponent);
     
     // Inside decode() and/or encode() of some custom component, validate if it has no children.
     Components.validateHasNoChildren(this);
     
     // Programmatically include composite component.
     Components.includeCompositeComponent(someParentComponent, libraryName, tagName, id);
     
     // Programmatically create value and action expressions.
     UICommand command = new HtmlCommandButton();
     command.setId("foo");
     command.setValue(Components.createValueExpression("#{bundle['button.foo']}", String.class));
     command.addClientBehavior("action", Components.createAjaxBehavior("#{bean.ajaxListener}"));
     command.addActionListener(Components.createActionListenerMethodExpression("#{bean.actionListener}"));
     command.setActionExpression(Components.createVoidMethodExpression("#{bean.action}"));
     
     // Programmatically capture HTML output of a given view.
     String mailHtml = Components.encodeHtml(Components.buildView("/WEB-INF/mail-template.xhtml"));
     
     // Collecting all queued actions and action listeners as method expression strings in a logging phase listener.
     List<String> actions = Components.getActionExpressionsAndListeners(Components.getCurrentActionSource());
     

    For a full list, check the method summary.

    Author:
    Bauke Scholtz, Arjan Tijms
    • Method Detail

      • getAttribute

        public static <T> T getAttribute​(UIComponent component,
                                         String name)
        Returns the attribute of the given component on the given name.
        Type Parameters:
        T - The expected return type.
        Parameters:
        component - The component to return the attribute of the given name for.
        name - The name of the attribute of the given component to be returned.
        Returns:
        The attribute of the given component on the given name.
        Throws:
        ClassCastException - When T is of wrong type.
        Since:
        1.5
      • isRendered

        public static boolean isRendered​(UIComponent component)
        Returns whether the given UI component and all of its parents is rendered. This thus not only checks the component's own rendered attribute, but also of all of its parents.
        Parameters:
        component - The component to be checked.
        Returns:
        true if the given UI component and all of its parents is rendered.
        Since:
        1.8
      • findComponent

        public static <C extends UIComponent> C findComponent​(String clientId)
        Returns the UI component matching the given client ID search expression.
        Type Parameters:
        C - The expected component type.
        Parameters:
        clientId - The client ID search expression.
        Returns:
        The UI component matching the given client ID search expression.
        Throws:
        ClassCastException - When C is of wrong type.
        See Also:
        UIComponent.findComponent(String)
      • findComponentRelatively

        public static <C extends UIComponent> C findComponentRelatively​(UIComponent component,
                                                                        String clientId)
        Returns the UI component matching the given client ID search expression relative to the point in the component tree of the given component. For this search both parents and children are consulted, increasingly moving further away from the given component. Parents are consulted first, then children.
        Type Parameters:
        C - The expected component type.
        Parameters:
        component - the component from which the relative search is started.
        clientId - The client ID search expression.
        Returns:
        The UI component matching the given client ID search expression.
        Throws:
        ClassCastException - When C is of wrong type.
        See Also:
        UIComponent.findComponent(String)
      • findComponentInParents

        public static <C extends UIComponent> C findComponentInParents​(UIComponent component,
                                                                       String clientId)
        Returns the UI component matching the given client ID search expression relative to the point in the component tree of the given component, searching only in its parents.
        Type Parameters:
        C - The expected component type.
        Parameters:
        component - the component from which the relative search is started.
        clientId - The client ID search expression.
        Returns:
        The UI component matching the given client ID search expression.
        Throws:
        ClassCastException - When C is of wrong type.
        See Also:
        UIComponent.findComponent(String)
      • findComponentInChildren

        public static <C extends UIComponent> C findComponentInChildren​(UIComponent component,
                                                                        String clientId)
        Returns the UI component matching the given client ID search expression relative to the point in the component tree of the given component, searching only in its children.
        Type Parameters:
        C - The expected component type.
        Parameters:
        component - the component from which the relative search is started.
        clientId - The client ID search expression.
        Returns:
        The UI component matching the given client ID search expression.
        Throws:
        ClassCastException - When C is of wrong type.
        See Also:
        UIComponent.findComponent(String)
      • findComponentsInChildren

        public static <C extends UIComponentList<C> findComponentsInChildren​(UIComponent component,
                                                                               Class<C> type)
        Returns a list of UI components matching the given type in children of the given component.
        Type Parameters:
        C - The generic component type.
        Parameters:
        component - The component to search in its children for UI components matching the given type.
        type - The type of the UI components to be searched in children of the given component.
        Returns:
        A list of UI components matching the given type in children of the given component.
      • findComponentsInCurrentForm

        public static <C extends UIComponentList<C> findComponentsInCurrentForm​(Class<C> type)
        Returns a list of UI components matching the given type in children of the currently submitted form. The currently submitted form is obtained by getCurrentForm().
        Type Parameters:
        C - The generic component type.
        Parameters:
        type - The type of the UI components to be searched in children of the currently submitted form.
        Returns:
        A list of UI components matching the given type in children of the currently submitted form.
        Since:
        3.1
      • getClosestParent

        public static <C extends UIComponent> C getClosestParent​(UIComponent component,
                                                                 Class<C> parentType)
        Returns from the given component the closest parent of the given parent type, or null if none is found.
        Type Parameters:
        C - The generic component type.
        Parameters:
        component - The component to return the closest parent of the given parent type for.
        parentType - The parent type.
        Returns:
        From the given component the closest parent of the given parent type, or null if none is found.
      • findClosestParent

        public static <C extends UIComponentOptional<C> findClosestParent​(UIComponent component,
                                                                            Class<C> parentType)
        Finds from the given component the closest parent of the given parent type.
        Type Parameters:
        C - The generic component type.
        Parameters:
        component - The component to find the closest parent of the given parent type for.
        parentType - The parent type.
        Returns:
        From the given component the closest parent of the given parent type.
        Since:
        3.11
      • forEachComponent

        public static Components.ForEach forEachComponent()
        Invokes an operation on every component in the component tree.

        This is a simplified version of regular component visiting that uses the builder pattern to provide the various optional parameters. Includes supports for only visiting components of a certain class type and two simplified functional interfaces / lambdas.

        See UIComponent.visitTree(VisitContext, VisitCallback)

        Returns:
        A new instance of Components.ForEach.
        Since:
        2.0
      • forEachComponent

        public static Components.ForEach forEachComponent​(FacesContext facesContext)
        Invokes an operation on every component in the component tree.

        This is a simplified version of regular component visiting that uses the builder pattern to provide the various optional parameters. Includes supports for only visiting components of a certain class type and two simplified functional interfaces / lambdas.

        See UIComponent.visitTree(VisitContext, VisitCallback)

        Parameters:
        facesContext - the faces context used for tree visiting
        Returns:
        A new instance of Components.ForEach, using the given faces context.
        Since:
        2.0
      • createComponent

        public static <C extends UIComponent> C createComponent​(String componentType)
        Creates a new component.
        Type Parameters:
        C - The generic component type.
        Parameters:
        componentType - The component type to create.
        Returns:
        The newly created component.
        Throws:
        ClassCastException - When C is of wrong type.
        Since:
        4.4
        See Also:
        Application.createComponent(String)
      • createComponent

        public static <C extends UIComponent> C createComponent​(FacesContext context,
                                                                String componentType)
        Creates a new component.
        Type Parameters:
        C - The generic component type.
        Parameters:
        context - The involved faces context.
        componentType - The component type to create.
        Returns:
        The newly created component.
        Throws:
        ClassCastException - When C is of wrong type.
        Since:
        4.4
        See Also:
        Application.createComponent(String)
      • includeFacelet

        public static void includeFacelet​(UIComponent parent,
                                          String path)
                                   throws IOException
        Include the Facelet file at the given (relative) path as child of the given UI component parent. This has the same effect as using <ui:include>. The path is relative to the current view ID and absolute to the webcontent root.
        Parameters:
        parent - The parent component to include the Facelet file in.
        path - The (relative) path to the Facelet file.
        Throws:
        IOException - Whenever given path cannot be read.
        Since:
        1.5
        See Also:
        FaceletContext.includeFacelet(UIComponent, String)
      • includeCompositeComponent

        public static UIComponent includeCompositeComponent​(UIComponent parent,
                                                            String libraryName,
                                                            String tagName,
                                                            String id)
        Create and include the composite component of the given library and resource name as child of the given UI component parent and return the created composite component. This has the same effect as using xmlns:my="http://xmlns.jcp.org/jsf/composite/libraryName and <my:tagName>. The given component ID must be unique relative to the current naming container parent and is mandatory for functioning of input components inside the composite, if any.
        Parameters:
        parent - The parent component to include the composite component in.
        libraryName - The library name of the composite component (path after "http://xmlns.jcp.org/jsf/composite/").
        tagName - The tag name of the composite component.
        id - The component ID of the composite component.
        Returns:
        The created composite component, which can if necessary be used to set more custom attributes on it.
        Since:
        1.5
      • includeCompositeComponent

        public static UIComponent includeCompositeComponent​(UIComponent parent,
                                                            String libraryName,
                                                            String tagName,
                                                            String id,
                                                            Map<String,​String> attributes)
        Create and include the composite component of the given library and resource name as child of the given UI component parent, set the given attributes on it and return the created composite component. This has the same effect as using xmlns:my="http://xmlns.jcp.org/jsf/composite/libraryName and <my:tagName>. The given component ID must be unique relative to the current naming container parent and is mandatory for functioning of input components inside the composite, if any.

        The attribute values must represent literal values or literal EL expressions, exactly like as you would declare in the view file. E.g.

         attributes.put("foo", "#{bean.foo}");
         attributes.put("bar", "true");
         attributes.put("baz", "#{bean.baz(" + someId + ")}");
         
        Parameters:
        parent - The parent component to include the composite component in.
        libraryName - The library name of the composite component (path after "http://xmlns.jcp.org/jsf/composite/").
        tagName - The tag name of the composite component.
        id - The component ID of the composite component.
        attributes - The attributes to be set on the composite component.
        Returns:
        The created composite component, which can if necessary be used to set more custom attributes on it.
        Since:
        2.2
      • addScript

        public static void addScript​(String script)
        Add given JavaScript code to the current view which is to be executed as an inline script when the rendering is completed. When the current request is Faces.isAjaxRequestWithPartialRendering(), then it will delegate to Ajax.oncomplete(String...), else it will add given JavaScript code as inline script to end of body.
        Parameters:
        script - JavaScript code which is to be executed as an inline script.
        Since:
        3.6
      • addScriptResource

        public static void addScriptResource​(String libraryName,
                                             String resourceName)
        Add given JavaScript resource to the current view. This will first check if the resource isn't already rendered as per ResourceHandler.isResourceRendered(FacesContext, String, String). If not, then continue as below:
        Parameters:
        libraryName - Library name of the JavaScript resource.
        resourceName - Resource name of the JavaScript resource.
        Since:
        3.6
      • addFacesScriptResource

        public static void addFacesScriptResource()
        Add the Faces JavaScript resource to current view. If Faces 4.0+ is present, then it will add the jakarta.faces:faces.js resource, else it will add the jakarta.faces:jsf.js resource.
        Since:
        4.0
      • encodeHtml

        public static String encodeHtml​(UIComponent component)
        Encodes the given component locally as HTML, with UTF-8 character encoding, independently from the current view. The current implementation, however, uses the current faces context. The same managed beans as in the current faces context will be available as well, including request scoped ones. But, depending on the nature of the provided component, the state of the faces context may be affected because the attributes of the context, request, view, session and application scope could be (in)directly manipulated during the encode. This may or may not have the desired effect. If the given view does not have any component resources, Faces forms, dynamically added components, component event listeners, then it should mostly be safe. In other words, use this at most for "simple templates" only, e.g. a HTML based mail template, which usually already doesn't have a HTML head nor body.
        Parameters:
        component - The component to capture HTML output for.
        Returns:
        The encoded HTML output of the given component.
        Throws:
        UncheckedIOException - Whenever something fails at I/O level. This would be quite unexpected as it happens locally.
        Since:
        2.2
        See Also:
        UIComponent.encodeAll(FacesContext)
      • getCurrentForm

        public static UIForm getCurrentForm()
        Returns the currently submitted UI form component, or null if there is none, which may happen when the current request is not a postback request at all, or when the view has been changed by for example a successful navigation. If the latter is the case, you'd better invoke this method before navigation.
        Returns:
        The currently submitted UI form component.
        See Also:
        UIForm.isSubmitted()
      • getCurrentCommand

        public static UICommand getCurrentCommand()
        Returns the currently invoked UI command component, or null if there is none, which may happen when the current request is not a postback request at all, or when the view has been changed by for example a successful navigation. If the latter is the case, you'd better invoke this method before navigation.
        Returns:
        The currently invoked UI command component.
        Since:
        1.6
      • getCurrentActionSource

        public static <C extends UIComponent> C getCurrentActionSource()
        Returns the source of the currently invoked action, or null if there is none, which may happen when the current request is not a postback request at all, or when the view has been changed by for example a successful navigation. If the latter is the case, you'd better invoke this method before navigation.
        Type Parameters:
        C - The expected component type.
        Returns:
        The source of the currently invoked action.
        Since:
        2.4
      • isEditable

        public static boolean isEditable​(UIInput input)
        Returns whether the given UI input component is editable. That is when it is rendered, not disabled and not readonly.
        Parameters:
        input - The UI input component to be checked.
        Returns:
        true if the given UI input component is editable.
      • getLabel

        public static String getLabel​(UIComponent component)
        Returns the value of the label attribute associated with the given UI component if any, else the client ID. It never returns null.
        Parameters:
        component - The UI component for which the label is to be retrieved.
        Returns:
        The value of the label attribute associated with the given UI component if any, else the client ID.
      • getOptionalLabel

        public static String getOptionalLabel​(UIComponent component)
        Returns the value of the label attribute associated with the given UI component if any, else null.
        Parameters:
        component - The UI component for which the label is to be retrieved.
        Returns:
        The value of the label attribute associated with the given UI component if any, else null.
      • setLabel

        public static void setLabel​(UIComponent component,
                                    Object label)
        Sets the label attribute of the given UI component with the given value.
        Parameters:
        component - The UI component for which the label is to be set.
        label - The label to be set on the given UI component.
      • getValue

        public static <T> T getValue​(EditableValueHolder component)
        Returns the value of the given editable value holder component without the need to know if the given component has already been converted/validated or not. Note that it thus returns the unconverted submitted string value when the conversion/validation hasn't been taken place for the given component and it returns the converted object value -if applicable- when conversion/validation has been taken place for the given component.
        Type Parameters:
        T - The expected return type.
        Parameters:
        component - The editable value holder component to obtain the value for.
        Returns:
        The value of the given editable value holder component.
        Throws:
        ClassCastException - When T is of wrong type.
      • getImmediateValue

        public static <T> T getImmediateValue​(UIInput input)
        Returns the value of the given input component whereby any unconverted submitted string value will immediately be converted/validated as this method is called. This method thus always returns the converted/validated value.
        Type Parameters:
        T - The expected return type.
        Parameters:
        input - The input component to obtain the converted/validated value for.
        Returns:
        The converted/validated value of the given input component.
        Throws:
        ClassCastException - When T is of wrong type.
        Since:
        1.2
      • hasSubmittedValue

        public static boolean hasSubmittedValue​(EditableValueHolder component)
        Returns whether the given editable value holder component has a submitted value.
        Parameters:
        component - The editable value holder component to be checked.
        Returns:
        true if the given editable value holder component has a submitted value, otherwise false.
      • getExpectedValueType

        public static <T> Class<T> getExpectedValueType​(UIComponent component)
        Returns the expected type of the "value" attribute of the given component. This is useful in among others a "generic entity converter".
        Type Parameters:
        T - The expected type of the expected type of the "value" attribute of the given component.
        Parameters:
        component - The component to obtain the expected type of the "value" attribute for.
        Returns:
        The expected type of the "value" attribute of the given component, or null when there is no such value.
        Throws:
        ClassCastException - When T is of wrong type.
        Since:
        3.8
      • getExpectedType

        public static <T> Class<T> getExpectedType​(ValueExpression valueExpression)
        Returns the expected type of the given value expression. This first inspects if the ValueExpression.getExpectedType() returns a specific type, i.e. not java.lang.Object, and then returns it, else it inspects the actual type of the property behind the expression string.
        Type Parameters:
        T - The expected type of the expected type of the given value expression.
        Parameters:
        valueExpression - The value expression to obtain the expected type for.
        Returns:
        The expected type of the given value expression.
        Throws:
        ClassCastException - When T is of wrong type.
        Since:
        3.8
      • hasInvokedSubmit

        public static boolean hasInvokedSubmit​(UIComponent component)
        Returns whether the given component has invoked the form submit. In non-ajax requests, that can only be an UICommand component. In ajax requests, that can also be among others an UIInput component.
        Parameters:
        component - The component to be checked.
        Returns:
        true if the given component has invoked the form submit.
        Since:
        1.3
      • getParams

        public static <T> List<ParamHolder<T>> getParams​(UIComponent component)
        Returns an unmodifiable list with all child UIParameter components (<f|o:param>) of the given parent component as a list of ParamHolder instances. Those with disabled=true and an empty name are skipped.
        Type Parameters:
        T - The type of the param value.
        Parameters:
        component - The parent component to retrieve all child UIParameter components from.
        Returns:
        An unmodifiable list with all child UIParameter components having a non-empty name and not disabled.
        Since:
        2.1
      • getParams

        public static Map<String,​List<String>> getParams​(UIComponent component,
                                                               boolean includeRequestParams,
                                                               boolean includeViewParams)
        Returns an unmodifiable map with all request query string or view parameters, appended with all child UIParameter components (<f|o:param>) of the given parent component. Those with disabled=true or an empty name or an empty value are skipped. The <f|o:param> will override any included view or request parameters on the same name.
        Parameters:
        component - The parent component to retrieve all child UIParameter components from.
        includeRequestParams - Whether or not to include request query string parameters. When set to true, then this overrides the includeViewParams.
        includeViewParams - Whether or not to include view parameters.
        Returns:
        An unmodifiable list with all request query string or view parameters, appended with all child UIParameter components having a non-empty name and not disabled.
        Since:
        2.4
      • getMessageComponent

        public static UIMessage getMessageComponent​(UIInput input)
        Returns the UIMessage component associated with given UIInput component. This returns null if none can be found.
        Parameters:
        input - The UI input component to find the associated message component for.
        Returns:
        The UIMessage component associated with given UIInput component.
        Since:
        2.5
      • getMessagesComponent

        public static UIMessages getMessagesComponent()
        Returns the first UIMessages component found in the current view. This returns null if none can be found.
        Returns:
        The first UIMessages component found in the current view.
        Since:
        2.5
      • resetForm

        public static void resetForm​(UIComponent component)
        Reset all child UIInput components enclosed in the given UIForm component, or the closest UIForm parent of it.
        Parameters:
        component - The component representing the UIForm itself, or to find the closest UIForm parent for.
        Throws:
        IllegalArgumentException - When given component is not an UIForm, or does not have a UIForm parent.
        Since:
        2.5
      • resetInputs

        public static void resetInputs​(UIComponent component)
        Reset all child UIInput components enclosed in the given parent component.
        Parameters:
        component - The parent component to reset all child UIInput components in.
        Since:
        2.5
      • addFormIfNecessary

        public static void addFormIfNecessary()
        Add an UIForm to the current view if absent. This might be needed for scripts which rely on Faces view state identifier and/or on functioning of jsf.ajax.request().
        Since:
        3.6
      • convertToString

        public static <T> String convertToString​(FacesContext context,
                                                 ValueHolder holder,
                                                 T value)
        Convert given value of given value holder to string using either the converter attached to the given value holder or the one obtained via Application.createConverter(Class) based on the type of the given value.
        Type Parameters:
        T - The generic value type.
        Parameters:
        context - The involved faces context.
        holder - The value holder.
        value - The value to be converted to string.
        Returns:
        The conversion result, may be null, depending on the value and the converter implementation.
        Since:
        4.1
      • createValueExpression

        public static ValueExpression createValueExpression​(String expression,
                                                            Class<?> type)
        Create an editable value expression based on the given EL expression and the given type.
        Parameters:
        expression - The EL expression to represent an editable value expression.
        type - The type of the property referenced by the value expression.
        Returns:
        The created editable value expression, ready to be used as UIComponent.setValueExpression(String, ValueExpression).
      • createMethodExpression

        public static MethodExpression createMethodExpression​(String expression,
                                                              Class<?> returnType,
                                                              Class<?>... parameterTypes)

        Create a method expression based on the given EL expression, the given return type and the given parameter types, if any. As an example, the following action method examples,

        • public void submit1()
        • public String submit2()
        • public void submit3(String argument)
        • public String submit4(String argument)
        • public void submit5(String argument1, Long argument2)
        • public String submit6(Long argument1, String argument2)

        can be created as follows:

        • createMethodExpression("#{bean.submit1}", Void.class);
        • createMethodExpression("#{bean.submit2}", String.class);
        • createMethodExpression("#{bean.submit3('foo')}", Void.class, String.class);
        • createMethodExpression("#{bean.submit4('foo')}", String.class, String.class);
        • createMethodExpression("#{bean.submit5('foo', 0)}", Void.class, String.class, Long.class);
        • createMethodExpression("#{bean.submit6(0, 'foo')}", String.class, Long.class, String.class);
        Parameters:
        expression - The EL expression to create a method expression for.
        returnType - The return type of the method expression. Can be null if you don't care about the return type (e.g. void or String).
        parameterTypes - The parameter types of the method expression.
        Returns:
        The created method expression, ready to be used as UICommand.setActionExpression(MethodExpression).
      • createVoidMethodExpression

        public static MethodExpression createVoidMethodExpression​(String expression,
                                                                  Class<?>... parameterTypes)

        Create a void method expression based on the given EL expression and the given parameter types, if any. As an example, the following action method examples,

        • public void submit1()
        • public void submit3(String argument)
        • public void submit5(String argument1, Long argument2)

        can be created as follows:

        • createVoidMethodExpression("#{bean.submit1}");
        • createVoidMethodExpression("#{bean.submit3('foo')}", String.class);
        • createVoidMethodExpression("#{bean.submit5('foo', 0)}", String.class, Long.class);
        Parameters:
        expression - The EL expression to create a void method expression for.
        parameterTypes - The parameter types of the void method expression.
        Returns:
        The created void method expression, ready to be used as UICommand.setActionExpression(MethodExpression).
      • createActionListenerMethodExpression

        public static MethodExpressionActionListener createActionListenerMethodExpression​(String expression)
        Create an action listener method expression based on the given EL expression. The target method must take an ActionEvent as argument. As an example, the following action method example,
        • public void actionListener(ActionEvent event)

        can be created as follows:

        • createActionListenerMethodExpression("#{bean.actionListener}");
        Parameters:
        expression - The EL expression to create an action listener method expression for.
        Returns:
        The created action listener method expression, ready to be used as UICommand.addActionListener(jakarta.faces.event.ActionListener).
      • createAjaxBehavior

        public static AjaxBehavior createAjaxBehavior​(String expression)
        Create an ajax behavior which should invoke an ajax listener method expression based on the given EL expression. The target method must take an AjaxBehaviorEvent as argument. As an example, the following ajax listener example,
        • public void ajaxListener(AjaxBehaviorEvent event)

        can be created as follows:

        • createAjaxBehavior("#{bean.ajaxListener}");

        Note that this is essentially the programmatic equivalent of <f:ajax>. So if you intented to create for example a <p:ajax> programmatically, then don't use this method.

        Parameters:
        expression - The EL expression to be invoked when the created ajax behavior is processed.
        Returns:
        The created ajax behavior, ready to be used as UIComponentBase.addClientBehavior(String, ClientBehavior) whereby the string argument represents the client event name, such as "action", "valueChange", "click", "blur", etc.
      • getActionExpressionsAndListeners

        public static List<String> getActionExpressionsAndListeners​(UIComponent component)
        Returns a list of all action expressions and listeners associated with given component. This covers expressions in action attribute of command components and listener attribute of ajax components. Any method expressions are in format #{bean.method} and any action listeners are added as fully qualified class names. This list is primarily useful for logging postback actions in a phase listener. You can use getCurrentActionSource() to obtain the current action source.
        Parameters:
        component - The component to retrieve all action expressions and listeners from.
        Returns:
        A list of all action expressions and listeners associated with given component.
        Since:
        2.4
      • validateHasParent

        public static <C extends UIComponent> void validateHasParent​(UIComponent component,
                                                                     Class<C> parentType)
        Validate in development stage if the given component has a parent of given parent type.
        Type Parameters:
        C - The generic component type.
        Parameters:
        component - The component to be validated.
        parentType - The parent type to be checked.
        Throws:
        IllegalStateException - When the given component doesn't have any parent of the given type.
      • validateHasDirectParent

        public static <C extends UIComponent> void validateHasDirectParent​(UIComponent component,
                                                                           Class<C> parentType)
        Validate in development stage if the given component has a direct parent of given parent type.
        Type Parameters:
        C - The generic component type.
        Parameters:
        component - The component to be validated.
        parentType - The parent type to be checked.
        Throws:
        IllegalStateException - When the given component doesn't have a direct parent of the given type.
      • validateHasNoParent

        public static <C extends UIComponent> void validateHasNoParent​(UIComponent component,
                                                                       Class<C> parentType)
        Validate in development stage if the given component has no parent of given parent type.
        Type Parameters:
        C - The generic component type.
        Parameters:
        component - The component to be validated.
        parentType - The parent type to be checked.
        Throws:
        IllegalStateException - When the given component does have a parent of the given type.
        Since:
        2.5
      • validateHasChild

        public static <C extends UIComponent> void validateHasChild​(UIComponent component,
                                                                    Class<C> childType)
        Validate in development stage if the given component has at least a child of given child type.
        Type Parameters:
        C - The generic component type.
        Parameters:
        component - The component to be validated.
        childType - The child type to be checked.
        Throws:
        IllegalStateException - When the given component doesn't have any children of the given type.
        Since:
        2.5
      • validateHasOnlyChildren

        public static <C extends UIComponent> void validateHasOnlyChildren​(UIComponent component,
                                                                           Class<C> childType)
        Validate in development stage if the given component has only children of given child type.
        Type Parameters:
        C - The generic component type.
        Parameters:
        component - The component to be validated.
        childType - The child type to be checked.
        Throws:
        IllegalStateException - When the given component has children of a different type.
        Since:
        2.5
      • validateHasNoChildren

        public static void validateHasNoChildren​(UIComponent component)
        Validate in development stage if the given component has no children.
        Parameters:
        component - The component to be validated.
        Throws:
        IllegalStateException - When the given component has any children.