if you use the oncreate, it's only in the zul you have to write the initialisation, not in the viewmodel. now you mix 2 solutions.
chillworld ( 2015-03-11 05:02:08 +0800 )edit-
FEATURED COMPONENTS
First time here? Check out the FAQ!
如题, 请问, <textbox value="@save(vm.mytext) 同时我想在界面打开时就有一个初始值,比如:abc,我试过用 @load('abc')但是,好象不能成功/> 请问正确的方法</p> ">
Hello streamif,
I did a google translate in order to understand your question.
So based on it you need a way to load an initial value to a component with mvvm. For this task please refer to the following url which provides a very good example of the mvvm pattern:
http://www.zkoss.org/zkdemo/composite/mvvm_pattern
Best Regards,
Darksu
<textbox value="@bind(vm.mytext)"/>
private String mytext="abc";
public void setMytext(String mytext) {
this.mytext = mytext;
}
public String getMytext () {
return mytext;
}
Greetz chill.
<textbox value="@save(vm.mytext)" onCreate='self.value="abc"' />
感谢热心的darksu和chillworld
chillworld的方法: 1、 private String mytext="abc";
public void setMytext(String mytext) { this.mytext = mytext; }
public String getMytext () { return mytext; }这个是肯定可以
2、<textbox value="@save(vm.mytext)" oncreate="self.value="abc""/>可以显示abc,如果修改则可以成功,如果不修改,则保存时为空
我这个问题的重点是,如果不在VM下初始化,通过ZUL页面是否可以完成对输入控件的初始化, 目前还没达到理想的效果,还请大家再商量如何解决...
if you use the oncreate, it's only in the zul you have to write the initialisation, not in the viewmodel. now you mix 2 solutions.
chillworld ( 2015-03-11 05:02:08 +0800 )editAsked: 2015-03-10 01:57:56 +0800
Seen: 24 times
Last updated: Mar 11 '15