我在访问 ViewModel 中的对象属性时遇到问题。我收到未到达的目的地错误。请问有什么指点吗?谢谢。
错误信息:
目标不可达,'toto' 返回 null
基本上,当我填写文本框并单击窗口中的某个位置时,我会收到错误消息。当我使用其他 ViewModel 的属性(它是一个字符串)时,它按我的预期工作。
设置:
我使用 JBoss Studio。该应用程序在 JBoss AS 7 上运行。基本上我按照本指南http://books.zkoss.org/wiki/ZK_Installation_Guide/Quick_Start/Create_and_Run_Your_First_ZK_Application_with_Eclipse_and_Maven创建我的项目。
祖尔文件:
<window apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('com.maylab.fault.TicketsViewModel')"
title="Trouble Ticket" width="600px" border="normal">
<hbox style="margin-top:20px">
<textbox value="@save(vm.toto.name)"></textbox>
<label value="@load(vm.toto.name)"></label>
</hbox>
</window>
视图模型:
package com.maylab.fault;
import org.zkoss.bind.annotation.*;
import com.maylab.fault.Person;
public class TicketsViewModel {
private String ticket;
private String test;
private Person toto;
public Person getToto() {
return toto;
}
public void setToto(Person toto) {
this.toto = toto;
}
public String getTest() {
return test;
}
public void setTest(String test) {
this.test = test;
}
public String getTicket() {
return ticket;
}
public void setTicket(String ticket) {
this.ticket = ticket;
}
}
人物类:
package com.maylab.fault;
public class Person {
private String name;
public Person(){
}
public Person(String name){
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}