0

Disabling and re-enabling components of a form once button is clicked

asked 2015-02-11 17:50:09 +0800

Antoc gravatar image Antoc
21 4

I have created a ZK application via MVC which provides a dialog which contains a form with a button and textboxes. In this form the startProcessButton should trigger, once it's clicked, a process that does a specific operation. While this operation is ongoing, the button and textboxes should be disabled. Once the operation is finished, the components should be enabled again. It seems simple, but the button and the textboxes don't seem to be disabled when the button is clicked. I expect the button to change style, but it remains the same as it is. I believe this is an event-related issue, but I don't have much experience in this matter. I would really appreciate help for this, thanks in advance!

public void onClick$startProcessButton(Event evt) { 
      disableAllComponents(true);
      startProcess();
}

private void startProcess() {

//do something

//re-enable the components
disableAllComponents(false);
}

private void disableAllComponents(Boolean condition) {

    if (condition) {
         startProcessButton.setSclass("button-disabled");
    } else {
         startProcessButton.setSclass("button");
    }

    startProcessButton.setDisabled(condition);
    registrationNumberTextBox.setDisabled(condition);
    accountHolderTitleComboBox.setDisabled(condition);
    accountHolderNameTextBox.setDisabled(condition);
    accountHolderSurnameTextBox.setDisabled(condition);
    accountHolderCodeTextBox.setDisabled(condition);
}
delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-02-11 20:21:17 +0800

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

updated 2015-02-11 20:23:36 +0800

If it's a long blocking operation you could do the following in the zul :

<button autodisable="self" />

If it's a non blocking operation, try this in the zul :

<button autodisable="+self" />

But you need to set the butto back correct in the controller after the long operation with :

button.setDisabled(false);

Now because you want to disable everything I suggest the following :

Clients.showBusy("Processing");

after the operation clear it with :

Clients.clearBusy();

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

Follow
1 follower

RSS

Stats

Asked: 2015-02-11 17:50:09 +0800

Seen: 46 times

Last updated: Feb 11 '15

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