这里我有一个ManagePageSource
其使用树视图提供模型mvvm
ZK的图案。
ManagePageSource
有一个内部类Node
持有treeNode的数据。
Node
有一个名称属性和ZK不能在ZUL文件中读取它。
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>
错误堆栈
>>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)
为什么名字是不是可读吗?