这里我有一个ManagePageSource
使用mvvm
zk 模式为 TreeView 提供模型。
ManagePageSource
有一个内部类Node
来保存 treeNode 数据。
Node
有一个 name 属性,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;
}
}
}
管理.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)
为什么名称在这里不可读?