0

Bugs on treeitem render after fireEvent TreeDataEvent.CONTENTS_CHANGED

asked 2012-01-03 11:33:25 +0800

Jales gravatar image Jales
161 1

updated 2012-01-03 11:39:10 +0800

Hi,

I'm using ZK version 5.0.9.

I think I found a bug on tree item render. It happens after updating data and then I invoke the fireEvent with TreeDataEvent.CONTENTS_CHANGED param.

This is a normal tree.

Picture 1 : normal

This is a (still normal) tree after changing the child of the first child of root

Picture 2 : still normal

But then, if I change the child of the other child of root (and it's child and so-on), and then invoke the fireEvent with the TreeDataEvent.CONTENTS_CHANGED,
it renders to be like this

Picture 3 : render error

The "Activity Test 2.1" renders as if it is the child of the "Activity Test 1".
The "Activity Test 2.1" is still the child of the "Activity Test 2" in the database, and if I reload the component, it renders normally.

I also notice that if I close the "Activity Test 2" (pay attention on Picture 3 that it's still showing "-" icon) the "Activity Test 2.1" disappears (see Picture 4 below).

Picture 4 : disappear

The "Activity Test 2" is now showing the "+" icon. And when I re-open the "Activity Test 2", it goes back to the same like Picture 3.

So, my conclusion is that the "Activity Test 2.1" IS still the child of the "Activity Test 2" but it renders as if it is the child of the "Activity Test 1".

And this doesn't happen with the child of the first child of the root. This also doesn't happen with the child of the root.

Does anyone have a workaround for this? Is this bug already fixed in 5.0.10? I heard that it's still not released yet, but if I need to, I will change to 5.0.10.

Update :

this is the implementation of the AbstractTreeModel
http://pastebin.com/aXgHFEZA

and this is the implementation of the TreeitemRenderer
http://pastebin.com/PMCZgxME

Thanks alot.

delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2012-01-03 15:20:34 +0800

Jales gravatar image Jales
161 1

Hi,

I managed to solve this by NOT removing the previous treerow and replace it with the new one

but ONLY replacing the value of the treerow.

In my TreeitemRenderer there is this code

     item.removeChild(item.getTreerow());
     item.appendChild(treerow);                   

I replace it with

   List<Treecell> treecells = item.getTreerow().getChildren();
   treecells.get(0).setLabel(activity.getActivityName());
   treecells.get(1).setLabel(activity.getActivityType().getParamValue());
   treecells.get(2).setLabel(formatter.format(activity.getActivityStart()));
   treecells.get(3).setLabel(formatter.format(activity.getActivityFinish()));

I'm reaching this conclusion because when I commented the part of the code that remove the previous treerow, and only using a setLabel for the Treeitem, I don't get the same error. So, basically it should be about replacing the previous value, not removing the previous treerow and replace it with a new one.

Thanks.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2012-01-03 11:33:25 +0800

Seen: 106 times

Last updated: Jan 03 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More