Revision history [back]

click to hide/show revision 1
initial version

answered 2014-02-20 08:45:41 +0800

chillworld gravatar image chillworld flag of Belgium

https://github.com/chillw...

No bug but bad practice of MVVM

do this :

zul :

<textbox value="@load(vm.textBoxValue) @save(vm.textBoxValue, before='saveData')"/>
<label value="@bind(vm.textBoxValue)" />
<button onClick="@command('saveData')" label="change"/>

VM :

private String textBoxValue;

@Command
public void saveData () {
    Messagebox.show("saveData " + textBoxValue);
}

public String getTextBoxValue() {
    return textBoxValue;
}

public void setTextBoxValue(String textBoxValue) throws WrongValueException  {
    System.out.println(textBoxValue);
    if (textBoxValue.equalsIgnoreCase("chillworld")) {
        throw new WrongValueException("chillworld not permitted");
    }
    this.textBoxValue = textBoxValue;
}

Greetz chill.

No bug but bad practice of MVVM

do this (the extra label is just for you to see when things happens) :

zul :

<textbox value="@load(vm.textBoxValue) @save(vm.textBoxValue, before='saveData')"/>
<label value="@bind(vm.textBoxValue)" />
<button onClick="@command('saveData')" label="change"/>

VM :

private String textBoxValue;

@Command
public void saveData () {
    Messagebox.show("saveData " + textBoxValue);
}

public String getTextBoxValue() {
    return textBoxValue;
}

public void setTextBoxValue(String textBoxValue) throws WrongValueException  {
    System.out.println(textBoxValue);
    if (textBoxValue.equalsIgnoreCase("chillworld")) {
        throw new WrongValueException("chillworld not permitted");
    }
    this.textBoxValue = textBoxValue;
}

Greetz chill.

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