java - Cannot load/save properties of the ViewModel's property -
i have problem accessing property of object inside viewmodel. got unreached destination error. pointers please? thanks.
error message:
target unreachable, 'toto' returned null
basically, error when fill in textbox , click somewhere in window. when use other viewmodel's property (which string), works expected.
setup:
i use jboss studio. app running on jboss 7. follow guide http://books.zkoss.org/wiki/zk_installation_guide/quick_start/create_and_run_your_first_zk_application_with_eclipse_and_maven create project.
zul file:
<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>
viewmodel:
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; } }
person class:
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; } }
if check viewmodel, have wrote code private person toto;
, get/set
method know toto=null
resolve issue have change code
private person toto = new person();
this resolve issue.
Comments
Post a Comment