You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Jorge Vásquez <jv...@3eyegroup.com> on 2007/02/02 18:46:18 UTC

Tree2 lazy loading + expand path issues...

Regards to all,

I am working on a view which uses the same user interaction rules as Windows
Explorer.  The idea is that I have a tree on the left and a detail for that
tree on the right.  Both views need to maintain synchronized and as in
Windows explorer there’s the possibility of navigating into a folder both
from the tree panel or from the details panel.  So far I can handle very
good the scenarios whenever the user is navigating from the tree (this means
I can handle the detail view updates satisfactorily according to the node
clicked on the tree).  My problem is trying to update the tree view (go to a
specific node) whenever the user clicks on a folder item in the details
view.  My issue here is that I am using the lazy loading scheme described in
the wiki (Alternative Tree2 Lazy Loading Method...by jtmille3) and whenever
I send the path to expand to it doesn’t expands in the tree view.  I tried
the same scenario in a view that doesn’t use lazy loading and it works
perfectly, therefore my question is if someone can orient me on what would
be the right approach to allow tree node expansion but using lazy loading.
(There’s also one obvious point to note:  the node expansion as maximum
happens one level at a time and up/down the current selected node, ‘cause
otherwise I accept that it would be totally impossible).  

 

This is my code fragment for the prototype action that I am using:

 

            public String expandNode() {

                        //Add the children under the node to expand first

                        TreeNode treeNode = _treeModel.getNodeById("0:0");

                        //Add the respective children in order to allow
expansion

                        AuthenticationBean authenticationBean =
(AuthenticationBean) FacesUtils

 
.getManagedBean("authenticationBean");

                        MessagesBean messagesBean = (MessagesBean)
FacesUtils.getManagedBean("messagesBean");                    

                        TreeNodeLazyLoading node000 = new
TreeNodeLazyLoading("actionNode", "0:0:0", "", "0:0:0", true, messagesBean

                                               .getLocalizedMessage("tree",
"workspaceOpenedIMG", authenticationBean

 
.getLanguageId()), messagesBean.getLocalizedMessage("tree",

                                               "workspaceClosedIMG",
authenticationBean.getLanguageId()));

                        TreeNodeLazyLoading node001 = new
TreeNodeLazyLoading("actionNode", "0:0:1", "", "0:0:1", true, messagesBean

                                               .getLocalizedMessage("tree",
"workspaceOpenedIMG", authenticationBean

 
.getLanguageId()), messagesBean.getLocalizedMessage("tree",

                                               "workspaceClosedIMG",
authenticationBean.getLanguageId()));               

                        treeNode.getChildren().add(node000);

                        treeNode.getChildren().add(node001);

                        String[] expandedPath = {"0", "0:0"};

                        _treeModel.getTreeState().expandPath(expandedPath);

                        return Constants.SUCCESS;

            }   

 

Note:  The Action method “expandNode” above is attempting a hard-coded
expansion of the first child node and before invoking the node to expand it
adds two leaf nodes under the node to expand to assure that all its
descendants are already in the model.

 

If anybody can help me explain why the node isn’t expanding and guide me to
a possible implementation that enables the combination of lazy-loading with
one-level at a time node expansion-collapse similar to the way Windows
explorer operates I would deeply appreciate him/her…

 

Thanks,

Jorge Vasquez