-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I came across a scenerio in my project:
Zul code:
<textbox onChange="@command('changeValue')"/>
<button onClick="@command('saveData')"/>
ViewModel code:
@command
public void changeValue(){
...some validation fails...
Messagebox.show("show some error on data change");
}
@command
public void saveData(){
...some validation fails...
Messagebox.show("some error in save");
.
.
....<some code>
}
Now when i change the value in text box and directly click on save button,Both the event get fired : first, onChange and then onClick of button.
Due to this both the error messages are shown.
I want that when first messagebox is shown ,the execution should stop and should allow only the first messagebox .
Thanxx in advance.
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.
Asked: 2014-02-20 07:27:38 +0800
Seen: 33 times
Last updated: Feb 20 '14
AutoComplete Combobox usage and requirements
Source code of page dosen't change when usinge an Include
my login/index zul page is loading twice, where as i am only calling it once
label in org.zkoss.zul.Messagebox must be middle aligned [closed]
Multiple date constraint prevents calendar days from getting disabled [closed]
Doublebox with format fails at the client side if typed number < 1.0E-6 [closed]