Class Selectors


  • public class Selectors
    extends java.lang.Object
    A collection of selector related utilities.
    Since:
    6.0.0
    Author:
    simonpai
    • Constructor Summary

      Constructors 
      Constructor Description
      Selectors()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.List<Component> find​(java.lang.String selector)
      Returns a list of Components that match the selector (from the first page of current Desktop).
      static java.util.List<Component> find​(Component root, java.lang.String selector)
      Returns a list of Components that match the selector.
      static java.util.List<Component> find​(Page page, java.lang.String selector)
      Returns a list of Components that match the selector.
      static java.lang.Iterable<Component> iterable​(Component root, java.lang.String selector)
      Returns an Iterable that iterates through all Components matched by the selector.
      static java.lang.Iterable<Component> iterable​(Page page, java.lang.String selector)
      Returns an Iterable that iterates through all Components matched by the selector.
      static java.util.List<VariableResolver> newVariableResolvers​(java.lang.Class<?> cls, java.lang.Class<?> untilClass)
      Creates a list of instances of VariableResolver based on the annotation of the given class.
      static void rewireComponentsOnActivate​(Component component, java.lang.Object controller)
      Rewire the components on session activation
      static void rewireVariablesOnActivate​(Component component, java.lang.Object controller, java.util.List<VariableResolver> extraResolvers)
      Rewire the variables on session activation
      static void wireComponents​(Component component, java.lang.Object controller, boolean ignoreNonNull)
      Wire components to controller.
      static void wireComponents​(Page page, java.lang.Object controller, boolean ignoreNonNull)
      Wire components to controller.
      static void wireEventListeners​(Component component, java.lang.Object controller)
      Add event listeners to components based on the controller.
      static void wireVariables​(Component component, java.lang.Object controller, java.util.List<VariableResolver> extraResolvers)
      Wire variables to controller, including XEL variables, implicit variables.
      static void wireVariables​(Page page, java.lang.Object controller, java.util.List<VariableResolver> extraResolvers)
      Wire variables to controller, including XEL variables, implicit variables.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Selectors

        public Selectors()
    • Method Detail

      • iterable

        public static java.lang.Iterable<Component> iterable​(Page page,
                                                             java.lang.String selector)
        Returns an Iterable that iterates through all Components matched by the selector.
        Parameters:
        page - the reference page for selector
        selector - the selector string
        Returns:
        an Iterable of Component
      • iterable

        public static java.lang.Iterable<Component> iterable​(Component root,
                                                             java.lang.String selector)
        Returns an Iterable that iterates through all Components matched by the selector.
        Parameters:
        root - the reference component for selector
        selector - the selector string
        Returns:
        an Iterable of Component
      • find

        public static java.util.List<Component> find​(Page page,
                                                     java.lang.String selector)
        Returns a list of Components that match the selector.
        Parameters:
        page - the reference page for selector
        selector - the selector string
        Returns:
        a List of Component
      • find

        public static java.util.List<Component> find​(Component root,
                                                     java.lang.String selector)
        Returns a list of Components that match the selector.
        Parameters:
        root - the reference component for selector
        selector - the selector string
        Returns:
        a List of Component
      • find

        public static java.util.List<Component> find​(java.lang.String selector)
        Returns a list of Components that match the selector (from the first page of current Desktop).
        Parameters:
        selector - the selector string
        Returns:
        a List of Component
        Since:
        9.5.0
      • wireVariables

        public static void wireVariables​(Component component,
                                         java.lang.Object controller,
                                         java.util.List<VariableResolver> extraResolvers)
        Wire variables to controller, including XEL variables, implicit variables.
        Parameters:
        component - the reference component
        controller - the controller object to be injected with variables
      • wireVariables

        public static void wireVariables​(Page page,
                                         java.lang.Object controller,
                                         java.util.List<VariableResolver> extraResolvers)
        Wire variables to controller, including XEL variables, implicit variables.
        Parameters:
        page - the reference page
        controller - the controller object to be injected with variables
      • wireComponents

        public static void wireComponents​(Component component,
                                          java.lang.Object controller,
                                          boolean ignoreNonNull)
        Wire components to controller.
        Parameters:
        component - the reference component for selector
        controller - the controller object to be injected with variables
        ignoreNonNull - ignore wiring when the value of the field is a Component (non-null) or a non-empty Collection.
      • wireComponents

        public static void wireComponents​(Page page,
                                          java.lang.Object controller,
                                          boolean ignoreNonNull)
        Wire components to controller.
        Parameters:
        page - the reference page for selector
        controller - the controller object to be injected with variables
        ignoreNonNull - ignore wiring when the value of the field is a Component (non-null) or a non-empty Collection.
      • rewireVariablesOnActivate

        public static void rewireVariablesOnActivate​(Component component,
                                                     java.lang.Object controller,
                                                     java.util.List<VariableResolver> extraResolvers)
        Rewire the variables on session activation
        Since:
        7.0.7
      • rewireComponentsOnActivate

        public static void rewireComponentsOnActivate​(Component component,
                                                      java.lang.Object controller)
        Rewire the components on session activation
        Since:
        7.0.7
      • wireEventListeners

        public static void wireEventListeners​(Component component,
                                              java.lang.Object controller)
        Add event listeners to components based on the controller.
        Parameters:
        component - the reference component for selector
        controller - the controller of event listening methods
      • newVariableResolvers

        public static java.util.List<VariableResolver> newVariableResolvers​(java.lang.Class<?> cls,
                                                                            java.lang.Class<?> untilClass)
        Creates a list of instances of VariableResolver based on the annotation of the given class. If no such annotation is found, an empty list is returned.
        Parameters:
        cls - the class to look for the annotation.
        untilClass - the class to stop the searching. By default, it will look for the annotation of the super class if not found. Ignored if null.