# Tree Render Bug?

mk
30

Hi

I think I have found a bug in the tree component.

If I declare the component within a zul file like this:
<tree model="${treemodel}" treeitemRenderer="${treeRenderer}">

"treemodel" and "treeRenderer" are declared ahead of the tree component within a <zscript> tag

The tree should be renderer on loading of the zul file with my "treeRenderer", but it is renderer with the default TreeitemRenderer.
As soon as I open the Treeitem, all following Treeitems are renderer correctly with my "treeRenderer".
If necessary I can provide a small example.

<zscript><![CDATA[
TestTreeitemRenderer treeRenderer = new TestTreeitemRenderer();

... (some data filling for demonstration purpose)...

SimpleTreeNode first = new SimpleTreeNode(ls.get(1), ls2);
SimpleTreeNode second = new SimpleTreeNode(ls.get(2), ls3);
SimpleTreeNode root = new SimpleTreeNode(ls.get(0), ls1);

SimpleTreeModel treemodel = new SimpleTreeModel(root);
]]></zscript>
<tree model="${treemodel}" treeitemRenderer="${treeRenderer}">
</tree>

I am using zk 3.50

mfg Michael

delete retag edit

## 6 Replies

dennis
3669 1 6
http://www.javaworld.com....

I cannot figure out your problem.
Do you mean, the first level nodes are rendered by default renderer, and other level nodes are rendered by your custom renderer?

mk
30

Yes.
The first level node is not renderer with my custom renderer. As soon as I open the tree my custom renderer is used. Also if I asign the same model through clicking a button, my custom renderer is used.

There is only a problem, if the page is loaded and the tree is initalized, and the first level nodes are rendered. It seems to ignore the assigned renderer and uses the default one.

mfg Michael

mk
30

I have found a solution to this problem.

<tree id="testt" model="${treemodel}" treeitemRenderer="${treeRenderer}"/>


with this code, the first treenodes are renderer with the default treeitemRenderer and looks like: [email protected]

But if you, assign the model, after the tree, within a zscript, it works fine and the nodes look like: "test1 3" "test2 3"
<tree id="testt" treeitemRenderer="${treeRenderer}"> </tree> <zscript><![CDATA[ testt.setModel(treemodel); ]]></zscript> mfg Michael answered 2008-09-18 01:36:30 +0800 dennis 3669 1 6 http://www.javaworld.com.... mm... Use ZUL tag did have sequence issue when assigning attribute in some components. I did not have sample to run your code. However, could you help us with following code to see if this work or not. <tree id="testt" treeitemRenderer="${treeRenderer}" model="\${treemodel}"/>

remove the zscript to set model and move the model attribute later than treeitemRenderer , thanks.

mk
30

Hi dennis

I was not aware that the ZUL tags had a special sequence order for attributes.
If I rearrange the attribute as you suggested, it works fine.

mfg Michael

dennis
3669 1 6
http://www.javaworld.com....

Hmm, Maybe we should post it to been a bug ,
check here, http://sourceforge.net/tracker/index.php?func=detail&aid=2124391&group_id=152762&atid=785191

[hide preview]