myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Robinson" <andrew.rw.robin...@gmail.com>
Subject Re: tree2 in MyFaces 1.1.1 and expanding
Date Mon, 10 Apr 2006 17:16:31 GMT
Getting closer, but this is still driving me nuts. I have replaced my
TreeState in my model with one that has a ton of 'System.out.println'
statements and have found, what I think is a vary bad bug in tree2 in
MyFaces 1.1.1.

My code for TreeState:
      public boolean isNodeExpanded(String nodeId)
      {
        System.out.println("STATE: checking " + nodeId);

          return (_expandedNodes.contains(nodeId) /*&& !getNode().isLeaf()*/);
      }

This is what I see when rendering:

11:48:12,879 INFO  [STDOUT] STATE: checking 0
11:48:12,882 INFO  [STDOUT] STATE: checking 0:0
11:48:12,884 INFO  [STDOUT] STATE: checking 0:1
11:48:12,886 INFO  [STDOUT] STATE: checking 0:2
11:48:12,888 INFO  [STDOUT] STATE: checking 0:3
11:48:12,890 INFO  [STDOUT] STATE: checking 0:4
11:48:12,893 INFO  [STDOUT] STATE: checking 0:5
11:48:12,895 INFO  [STDOUT] STATE: checking 0:5:0
11:48:12,897 INFO  [STDOUT] STATE: checking 0:5:1
11:48:12,899 INFO  [STDOUT] STATE: checking 0:5:2
11:48:12,901 INFO  [STDOUT] STATE: checking 0:5:3
11:48:12,908 INFO  [STDOUT] STATE: checking 0:6

The tree is not checking node IDs! It is using the index of the child
within the parent to show/store expanded state. This really doesn't
make sense. The code for treeState shows the arguments as "nodeId"
which definitely tells one that it is tracking expanded state via node
ID and not node position.

So, digging further into this confusion, I was deep in the code of the
HtmlTreeRenderer. In there it doesn't some really funky code. It sets
the tree's nodeId to this positional concatenated string then asks the
tree if it is expanded. The real nodeIds of the nodes are never used
(in fact the getIdentifier() property of a node is completely useless
when it comes to the expanded state of the tree).

Well that is the problem, not sure yet how to fix it or how to build a
nasty workaround. I will look at SVN current to see if it was fixed
there.

-Andrew


On 4/10/06, Hans Sowa <hanssowa@gmail.com> wrote:
> Hi
>
> I have the same problem so it would be great if anyone could answer. I'm
> sure that I give the path correctly but the tree doesn't expand the path and
> I can't find a problem on my side.
>
> Thanks.
>
>  2006/4/8, Andrew Robinson <andrew.rw.robinson@gmail.com>:
> > I am stumped on tree2 and expanding. I've looked through the source
> > and I can't figure out what is wrong.
> >
> > I have a backing bean tied to the user's session. That bean has a tree
> > model that is TreeModelBase. The value of my tree2 component is tied
> > to my backing bean's model instance. I have server side expansion
> > working as I am lazy-loading my tree nodes (I can have over 100,000
> > nodes).
> >
> > When I use the UI to expand/collapse the nodes, everything is working
> > fine. Even across multiple server calls, the expanded state is being
> > tracked fine.
> >
> > I have a search button that is searching the tree and when found,
> > selects and highlights the tree node. The nodes are not being expanded
> > in the view though. Here is the code (inside of an action listener
> > method that is NOT immediate):
> >
> >       List<String> ids = new ArrayList<String>();
> >       for (DimensionMember member = selectedMember; member != null;
> >         member = member.getParent())
> >         ids.add(0, member.getId());
> >
> >       // add the root node
> >       ids.add(0, "root:" + dimension.getName());
> >
> >       for (String id : ids)
> >       {
> >         System.out.println("A: Adding ID to expanded: " + id);
> >       }
> >       for (String id : ids.toArray(new String[ids.size()]))
> >       {
> >         System.out.println("B: Adding ID to expanded: " + id);
> >       }
> >
> >       treeModel.getTreeState().expandPath(ids.toArray(new
> String[ids.size()]));
> >
> > As you can see, I am doing so printing to the console for sanity
> > checks. The correct node IDs are being added to the expanded state,
> > yet the nodes are still collapsed in the rendered HTML.
> >
> > I have tried setting the transient flag on the state to make sure it
> > is using the backing bean, but that made no difference. Code:
> >     treeModel = new TreeModelBase(new MemberTreeRootNode());
> >     treeModel.getTreeState().setTransient(true);
> >
> > I just can't figure out why the tree refuses to expand my nodes when
> > executed programmatically.
> >
> > Any ideas?
> >
> > Thanks,
> > Andrew
> >
>
>
>
>
> --
> mfg Hans Sowa
> mailto:hanssowa@gmail.com

Mime
View raw message