0

Why tree's items are displayed like a pointer in MVVM?

asked 2012-05-28 05:02:14 +0800

edwpotapoff gravatar image edwpotapoff
43 1

Example zul:

            <tree model="@load(vm.definitions)" selectedItem="@bind(vm.selected)" checkmark="true">
                <treecols visible="false">
                    <treecol label="" />
                </treecols>
                <treechildren>
                    <template name="model" var="definition">
			<treeitem>
                            <treerow>
                                <treecell label="@load(definition.name)" />
                            </treerow>                        
                        </treeitem>
                    </template>
                </treechildren>
            </tree>

items in View Model:

    private TreeModelDefinition definitions;

and TreeModelDefinition:

public class TreeModelDefinition extends AbstractTreeModel<Definition> {

        public boolean isLeaf(Definition e) {
          ...
        }

        public Definition getChild(Definition e, int i) {
            ....
        }

        public int getChildCount(Definition e) {
            ...
        }
}

delete flag offensive retag edit

13 Replies

Sort by ยป oldest newest

answered 2012-12-26 17:47:46 +0800

simbo gravatar image simbo
74 2

Here is a complete tree mvvm on-demand answer on stackoverflow:

http://stackoverflow.com/questions/13684999/zk-how-to-create-a-load-on-demand-tree-with-databinding-interaction/14044063#14044063

The fully working sample code is on github.com at https://github.com/simbo1905/zktreemvvm

link publish delete flag offensive edit

answered 2012-05-30 01:12:59 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

Can you prepare the test case in ZK Fiddle and pass link here so we can try it on line?

http://zkfiddle.org/

link publish delete flag offensive edit

answered 2012-05-31 21:42:25 +0800

edwpotapoff gravatar image edwpotapoff
43 1

I begun preparing the test with Hello World, but compiler generated errors: http://zkfiddle.org/sample/t8u454/1-Hello-World-MVVM-2

link publish delete flag offensive edit

answered 2012-06-01 10:19:39 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

Did you forget to add "class"?

public class HelloViewModel {

link publish delete flag offensive edit

answered 2012-06-02 06:48:06 +0800

edwpotapoff gravatar image edwpotapoff
43 1

test Tree here: http://zkfiddle.org/sample/1pkf6ee/1-test-Tree-MVVM

In this test shown another problem: Title of window must update on "test Title".

link publish delete flag offensive edit

answered 2012-06-19 07:53:07 +0800

szarza gravatar image szarza
62 2
http://balteus.blogspot.c...

Hello:
Same for me. Any solutions?

link publish delete flag offensive edit

answered 2012-06-19 10:41:11 +0800

edwpotapoff gravatar image edwpotapoff
43 1

multiple don't work:
http://zkfiddle.org/sample/1pkf6ee/3-test-Tree-MVVM

link publish delete flag offensive edit

answered 2012-06-22 02:58:54 +0800

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

when using tree with model, you have to set multiple on the model.(see TreeSelectableModel interface)
ex,
definitions = new TreeModelDefinition( root );
definitions.setMultiple(true);

and for the selection on multiple, you need to bind to selectedItems

link publish delete flag offensive edit

answered 2012-06-22 03:12:00 +0800

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

updated 2012-06-22 03:12:55 +0800

for the displaying like a pointer, it looks like a kind of weird bug when using tree+model and treechildren.
basically, you shouldn't add tree-children in the code, (here is a tree template example with normal EL , http://books.zkoss.org/wiki/ZK_Developer's_Reference/MVC/View/Template/Tree_Template)

and for your case, try this

            <tree model="@load(vm.definitions)" selectedItem="@bind(vm.selected)" checkmark="true">
                <treecols visible="false">
                    <treecol label="" ></treecol>
                </treecols>
                    <template name="model" var="definition">
			<treeitem>
                            <treerow>
                                <treecell label="@load(definition.name)" ></treecell>
                            </treerow>                        
                        </treeitem>
                    </template>
            </tree>

link publish delete flag offensive edit

answered 2012-06-22 03:43:05 +0800

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

updated 2012-06-22 03:48:04 +0800

got it,this is not bug, for the tree's template, it has to be in tree directly, if you put it in children, then render cannot find it, and a default one will be applied.

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-05-28 05:02:14 +0800

Seen: 730 times

Last updated: Dec 26 '12

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