Here i have a ManagePageSource
which provide Model for TreeView using mvvm
pattern of zk.
ManagePageSource
has a inner class Node
to hold treeNode Data.
Node
has a name property and zk is not able to read it in zul file.
public class ManagePageSource implements Serializable{
private static final long serialVersionUID = 1L;
private TreeModel treeModel = null;
public TreeModel getTreeModel() {
TreeNode<Node>[] children = null;
// create a node
TreeNode<Node> node = new DefaultTreeNode<Node>(new Node("child"), children);
// add child node to a node
node.add(new DefaultTreeNode<Node>(new Node("child2")));
// create treeModel and set nodes
treeModel = new DefaultTreeModel(node);
return treeModel;
}
// Inner class for holding tree data
class Node implements Serializable{
private static final long serialVersionUID = 1L;
private String name = null;
public Node(String name){
this.name = name;
}
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
}
}
Manage.zul
<window apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('ManagePageSource')">
<tree model="@load(vm.treeModel)">
<treecols>
<treecol label="Path" />
</treecols>
<template name="model">
<treeitem>
<treerow>
<treecell label="@load(each.data.name)" />
</treerow>
</treeitem>
</template>
</tree>
</window>
error stack
>>org.zkoss.zel.PropertyNotFoundException: Property 'name' not readable on type ManagePageSource$Node
>> at org.zkoss.zel.BeanELResolver$BeanProperty.read(BeanELResolver.java:409)
>> at org.zkoss.zel.BeanELResolver$BeanProperty.access$000(BeanELResolver.java:320)
Why name is not readable here ?