0

ZK5: tree with model drag n drop -> orange error box when changing model

asked 2010-01-21 13:15:02 +0800

madruga0315 gravatar image madruga0315 flag of Brazil
937 2 12

I believe that this is related to tree being rendered on client now.

As it's envolve data binding, tree model, it's kind difficult to provide a reproducible sample, but If needed, I'll try to make a simple project to reproduce this.

In short, it's a with a SimpleTreeModel and a TreeitemRenderer and a initTree() method which generates the model and then assign it to the tree.model

the 1st call to initTree() is on afterCompose, and it works. The problem, is that after a drag n drop action, that I get some data from attributes, and then call initTree() again (which will just replace tree.model with a new one). Then the orange error box appears with

"Failed to process
addChd
undefined"

Tested with ZK5 21/01/2010 on GC and FF.
Is this info enough? Or should I make a simple reproducible project?

Thanks

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2010-01-21 21:51:22 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

Hi,

Please provide a simple sample?
BTW, the ZK 5 release is targeted next week.

link publish delete flag offensive edit

answered 2010-01-22 09:42:03 +0800

madruga0315 gravatar image madruga0315 flag of Brazil
937 2 12

updated 2010-01-22 09:43:03 +0800

Hi Jumper,

I've made a simple test case, not sure is the same error, because in this one the app just hang (js exception on firebug) instead of the orange error.

It's just an tree with a model, and on the drop event re-assign the model. It uses BinaryTreeModel and BigList from zkdemo.


tree.zul

<zk>
    <label value="ZK Version: ${desktop.webApp.version}"/>
    Drag n drop to hang
    <tree id="tree" apply="TreeComposer" />
</zk>


TreeComposer.java

public class TreeComposer extends GenericForwardComposer{
    Tree tree;

    @Override
    public void doAfterCompose(Component component) throws java.lang.Exception {
        super.doAfterCompose(component);

        tree.setTreeitemRenderer(new TreeDragDropRender());

        initializeTree();
    }

    public void onDropTreerow() {
        initializeTree();
    }

    private void initializeTree() {
        tree.setModel(new BinaryTreeModel(new ArrayList(new org.zkoss.zkdemo.userguide.BigList(10))));
    }

    class TreeDragDropRender implements TreeitemRenderer {
        public void render(Treeitem item, Object data) throws Exception {
            if(data != null) {
                //Contruct treecells
                Treecell tc = new Treecell(data.toString());
                Treerow tr;

                /*
                 * Since only one treerow is allowed, if treerow is not null,
                 * append treecells to it. If treerow is null, contruct a new
                 * treerow and attach it to item.
                 */
                if(item.getTreerow() == null) {
                    tr = new Treerow();
                    tr.setParent(item);
                } else {
                    tr = item.getTreerow();
                    tr.getChildren().clear();
                }

                //Attach treecells to treerow
                tc.setParent(tr);

                item.setOpen(true);

                tr.setDraggable("true");
                tr.setDroppable("true");

                ComponentsCtrl.applyForward(tr, "onDrop=onDropTreerow");
            }
        }
    }
}

link publish delete flag offensive edit

answered 2010-01-25 01:06:35 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

Hi,

I post a bug here - bug tracker.
Please follow it.

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: 2010-01-21 13:15:02 +0800

Seen: 722 times

Last updated: Jan 25 '10

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