-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello,
i have one zul page and from these i open another modal zul page.
when i close the modal zul page i want to do something like bring some warnings etc so i think it would be a simple way to use a onclose event. but how?
greets
You have to catch ten onOpen-event. This event is used for both: open and close (isOpen()).
/Robert
Hi moloch,
You try and modify from the following example:
1. In your zk.xml, turn on the event thread
<system-config> <disable-event-thread>false</disable-event-thread> </system-config>
2. try the following zul
<window title="win" border="normal" width="200px" height="200px" closable="true"> <attribute name="onClose"><![CDATA[ if(Messagebox.show("Are you sure to close the window?", "Question", Messagebox.OK | Messagebox.CANCEL, Messagebox.QUESTION) != Messagebox.OK){ event.stopPropagation(); } ]]></attribute> </window>
Regards,
Simon
1. By using the GenericForwardComposer you can get it per naming convention. --> onClose$myWindow(Event event) {}
/** * If we close the dialog window. <br> * * @param event * @throws Exception */ public void onClose$window_GuestBookDialog(Event event) throws Exception { doClose(); } /** * Closes the dialog window. <br> * <br> * Before closing we check if there are unsaved changes in <br> * the components and ask the user if saving the modifications. <br> * */ private void doClose() throws Exception { if (isDataChanged()) { // Show a confirm box final String msg = Labels.getLabel("message_Data_Modified_Save_Data_YesNo"); final String title = Labels.getLabel("message.Information"); MultiLineMessageBox.doSetTemplate(); if (MultiLineMessageBox.show(msg, title, MultiLineMessageBox.YES | MultiLineMessageBox.NO, Messagebox.QUESTION, true, new EventListener() { @Override public void onEvent(Event evt) { switch (((Integer) evt.getData()).intValue()) { case MultiLineMessageBox.YES: try { doSave(); } catch (final InterruptedException e) { throw new RuntimeException(e); } case MultiLineMessageBox.NO: break; // } } } ) == MultiLineMessageBox.YES) { } } this.window_GuestBookDialog.onClose(); }
2. otherise you can add an EventListener manually to your Window.
myWindow.addEventListener("onClose", new EventListener() { @Override public void onEvent(Event event) throws Exception { // TODO Auto-generated method stub } });
best
Stephan
my solution is this
Window win = new Window(); win = (Window) Executions.createComponents("/WEB-INF/pages/zul/my.zul", null, map); win.doModal(); //when the modal window is closed i can do anything here at this line
should anybody tell why i need the zk.xml with this property so my solution is working?
<system-config> <disable-event-thread>false</disable-event-thread> </system-config>
Asked: 2010-08-24 09:20:05 +0800
Seen: 2,040 times
Last updated: Sep 07 '10