anjingjing
(Jingjing An)
November 22, 2018, 9:15am
#1
Hi,
For some reason, when user choose “Leave”, I need my webclient to exit(close current browser tab).
I try to invoke close(CLOSE_ACTION_ID, true); in my AbstractMainWindow code, but raise error that :
UnsupportedOperationException: Close operation for TopLevelWindow is unsupported
How to acheive that close current browser tab?
artamonov
(Yuriy Artamonov)
November 22, 2018, 9:20am
#2
You cannot close the main window using close. Use the following code to close the browser tab:
JavaScript js = Page.getCurrent().getJavaScript();
js.execute("window.close();");
It does not logout user from the application, it only closes the corresponding browser tab.
anjingjing
(Jingjing An)
November 22, 2018, 9:41am
#3
Thanks for quick reply.
But it does not work, mainwindow still remains.
I add that code in a popup window close listener.
AbstractLookup editor = (AbstractLookup) openWindow("ubs$SelectUserDuty.edit", WindowManager.OpenType.DIALOG);
editor.addCloseListener((String actionId) -> {
if (actionId == Window.COMMIT_ACTION_ID) {
// some logic
} else {
JavaScript js = Page.getCurrent().getJavaScript();
js.execute("window.close();");
}
});