-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I'm working with dynamically updated Tree and TreeitemRenderer, and ZK 6.0.2
It seems to me that after updating Treeitem's value with the new DefaultTreeNode and it's node's data, the onOpen event listener that I previously added to the Treeitem seems to be "lost in space": the treeitem says that the listener is avaliable but it's not executed any more.
Curiously, the onRightClick works perfectly, but the onOpen doesn't work if the row has been updated more than once, even if the event listeners are added on the same way.
Sample code
public void render(Treeitem treeItem, Object data, int arg2) throws Exception { DefaultTreeNode treeNode = (DefaultTreeNode) data; treeItem.setValue(treeNode); Treerow tr = treeItem.getTreerow(); if(tr == null) { tr = new Treerow(); } else { tr.getChildren().clear(); } treeItem.appendChild(tr); MyRowData row = (MyRowData)treeNode.getData(); tr.appendChild(new Treecell()); // Add my information to the row... if (!row.isLeaf())) { if (!treeItem.isListenerAvailable(Events.ON_OPEN, true)) { treeItem.addEventListener(Events.ON_OPEN, new EventListener() { public void onEvent(Event event) throws Exception { Treeitem ti=(Treeitem)event.getTarget(); DefaultTreeNode dtn=(DefaultTreeNode)ti.getValue(); MyRowData row = (MyRowData )dtn.getData(); row.setOpen(((OpenEvent)event).isOpen()); } }); treeItem.addEventListener(Events.ON_RIGHT_CLICK, new EventListener() { public void onEvent(Event event) throws Exception { ((Treeitem)event.getTarget()).setSelected(true); } }); } if (tr.getContext()==null) { Menupopup popup=new Menupopup(); popup.setPage(treeItem.getPage()); popup.setWidth("300px"); // Add some menus Menuitem mnc=new Menuitem("MyMenu"); mnc.setImage("/images/myimage.gif"); ComponentsCtrl.applyForward(mnc, "myid.onClick"); popup.appendChild(mnc); tr.setContext(popup); } } treeItem.setOpen(row.isOpen()); }
I've also introduced the org.zkoss.zk.ui.EventListener.duplicateIgnored property on zk.xml, and it doesn't changes the problem.
I've also added a new event listener at the same point as onOpen, (onDoubleClick) and it also works, but not the onOpen.
Any idea?
Asked: 2012-08-08 10:23:59 +0800
Seen: 111 times
Last updated: Sep 13 '12