Stop further execution after messagebox.show()

asked 2014-02-20 07:27:38 +0800

nsharma gravatar image nsharma flag of India
917 1 11

updated 2014-02-20 07:29:16 +0800

I came across a scenerio in my project:

Zul code:

<textbox onChange="@command('changeValue')"/>

<button onClick="@command('saveData')"/>

ViewModel code:

    public void changeValue(){
...some validation fails...
    Messagebox.show("show some error on data change");

    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.

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

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

chillworld gravatar image chillworld flag of Belgium
5337 4 9

updated 2014-02-20 08:46:49 +0800

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;

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

public String getTextBoxValue() {
    return textBoxValue;

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

Greetz chill.

link publish delete flag offensive 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

1 follower



Asked: 2014-02-20 07:27:38 +0800

Seen: 32 times

Last updated: Feb 20 '14

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