-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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.setClosable(true);
tab.setParent(mainTab.getTabs());
tab.addEventListener("onSwitchTab", new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
handleSwitchEvent(event);
}
});
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.
Asked: 2013-09-20 12:39:10 +0800
Seen: 14 times
Last updated: Sep 20 '13
anybody.....????
nsharma ( 2013-10-03 14:24:36 +0800 )edit