-
FEATURED COMPONENTS
First time here? Check out the FAQ!
1 | initial version | |
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.
2 | No.2 Revision |
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.