Issue in Tab close event enhancement

asked 2013-09-20 12:39:10 +0800

nsharma gravatar image nsharma flag of India
917 1 11

updated 2013-09-20 12:42:32 +0800

Hi everyone, Well I am facing this issue and haven't got any solution so far.

My requirement was to put a check on close event of tab ,so that whenever user clicks on tab's close button,user should be prompted if some changes are been done in the tab data: "Do u really want to exit? yes or no" .For this I created my own event:

    Tab tab = new Tab(title);

    tab.addEventListener("onSwitchTab", new EventListener<Event>() {

        public void onEvent(Event event) throws Exception {

and overrided the tab's onclose event with event:

tab.setWidgetOverride("onClose", "function(notify, init) {zAu.send(new zk.Event(this, 'onSwitchTab'));event.stopPropagation();}");

Now in handleSwitchEvent(event) method i did:


.code to check whether the data is changed in closing tab.



If YES, show a messegebox:

Messagebox.show("something", "title", Messagebox.OK
                        | Messagebox.CANCEL, Messagebox.QUESTION, new EventListener<Event>() {

                    public void onEvent(Event event) throws Exception {
                        String evtName = event.getName();

                        if (Messagebox.ON_OK.equals(evtName)) {
                            Events.sendEvent(new Event(Events.ON_CLOSE, tab, null));
                        } else if (Messagebox.ON_CANCEL.equals(evtName)) {
                            // do nothing


Now on when user clicks OK button ,everything goes fine.

//If No,i.e Lets now consider no data was changed in tab,for that simply I called

Events.sendEvent(new Event(Events.ON_CLOSE, tab, null));

now suppose there are two tabs opened ,with no change done,user tries to close the first tab: and gets a exception:

exactly one selected tab is required[].

The error is coming from some event(possibly onSelect) fired internally inside zk code,after everything is been executed,i have tried to fire a onSelect for myself,but didn't got any help.

delete flag offensive retag edit



nsharma ( 2013-10-03 14:24:36 +0800 )edit
Be the first one to answer this question!
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: 2013-09-20 12:39:10 +0800

Seen: 14 times

Last updated: Sep 20 '13

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