Class NavNodeChildLoador<T,​O,​M,​B extends NavBridge<M,​N>,​N extends NavNode<M,​N>>

  • Type Parameters:
    T - type of data used to create nodes (can be just a String type to use only ids)
    O - type of data associated with nodes
    N - type of node to used (to make possible full co-variance and no cast in fal implementations).
    All Implemented Interfaces:
    Serializable
    Direct Known Subclasses:
    NavTreeNodeChildLoador, NavTreeTableNodeChildLoador

    public abstract class NavNodeChildLoador<T,​O,​M,​B extends NavBridge<M,​N>,​N extends NavNode<M,​N>>
    extends Object
    implements Serializable
    Object to load childs of a node. It uses NavDataProvider in method loadChilds(NavBridge, NavNode, NavDataProvider) to obtain datas then build childs nodes. A factory of such objects can be found in NavHelper to make them reusable in other places than inside a NavNode to auto-load childs. For example when you want to creat by hand a new node, always prefer to reuse a such object rathen than duplicate same code in helper...
    Since:
    2.1
    Author:
    Tony Chemit - dev@tchemit.fr
    See Also:
    NavHelper, NavNode, Serialized Form
    • Field Detail

      • beanType

        protected final Class<O> beanType
        Type of data of the node
    • Constructor Detail

      • NavNodeChildLoador

        protected NavNodeChildLoador​(Class<O> beanType)
    • Method Detail

      • getData

        public abstract List<T> getData​(Class<?> parentClass,
                                        String parentId,
                                        NavDataProvider dataProvider)
        Obtain the list of data used to create nodes. If type T is O, we directly use the data associated with nodes.
        Parameters:
        parentClass - type of parent
        parentId - id of parent
        dataProvider - the data provider
        Returns:
        the list of data
        Throws:
        Exception - if any problem
      • createNode

        public abstract N createNode​(T data,
                                     NavDataProvider dataProvider)
        Hook to create a child node given his data.
        Parameters:
        data - the data of the node to create
        dataProvider - the data provider
        Returns:
        the created node
      • getBeanType

        public Class<O> getBeanType()
        Returns the type of data associated with nodes to create.
        Returns:
        the type of data associated with created nodes.
      • loadChilds

        public void loadChilds​(B bridge,
                               N parentNode,
                               NavDataProvider dataProvider)
        Load childs of the given parentnode.
        Parameters:
        bridge - the model owner of nodes
        parentNode - the parent node where to insert nodes
        dataProvider - data provider
        Throws:
        Exception - pour tout probleme de recuperation de donnees
      • addChildNodes

        protected void addChildNodes​(N parentNode,
                                     List<T> datas,
                                     NavDataProvider dataProvider)
        Add childs to given parentNode using retrive datas from the data provider. This method is invoked by the loadChilds(NavBridge, NavNode, NavDataProvider).
        Parameters:
        parentNode - the node where to insert
        datas - the data used to create node
        dataProvider - the data provider