0

mvvm模式下,textbox或combobox如何在ZUL中设定初始值

asked 2015-03-10 01:57:56 +0800

streamif gravatar image streamif
15

如题, 请问, <textbox value="@save(vm.mytext) 同时我想在界面打开时就有一个初始值,比如:abc,我试过用 @load('abc')但是,好象不能成功/&gt; 请问正确的方法&lt;/p&gt; ">

delete flag offensive retag edit

3 Answers

Sort by » oldest newest most voted
0

answered 2015-03-10 15:38:37 +0800

Darksu gravatar image Darksu
1991 1 4

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

link publish delete flag offensive edit
0

answered 2015-03-10 20:03:33 +0800

chillworld gravatar image chillworld flag of Belgium
5337 4 9
https://github.com/chillw...

updated 2015-03-11 05:01:18 +0800

Zul:

<textbox value="@bind(vm.mytext)"/>

ViewModel:

private String mytext="abc";

public void setMytext(String mytext) {
    this.mytext = mytext;
}

public String getMytext () {
    return mytext;
}

Greetz chill.

Solution 2:

<textbox value="@save(vm.mytext)" onCreate='self.value="abc"' />
link publish delete flag offensive edit
0

answered 2015-03-11 01:07:12 +0800

streamif gravatar image streamif
15

感谢热心的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页面是否可以完成对输入控件的初始化, 目前还没达到理想的效果,还请大家再商量如何解决...

link publish delete flag offensive edit

Comments

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
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2015-03-10 01:57:56 +0800

Seen: 24 times

Last updated: Mar 11 '15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More