0

how to catch onclose event from a modal window

asked 2010-08-24 09:20:05 +0800

moloch gravatar image moloch
606 1 13

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

delete flag offensive retag edit

9 Replies

Sort by ยป oldest newest

answered 2010-08-24 13:14:40 +0800

robertpic71 gravatar image robertpic71
1275 1

You have to catch ten onOpen-event. This event is used for both: open and close (isOpen()).

/Robert

link publish delete flag offensive edit

answered 2010-08-25 01:07:10 +0800

moloch gravatar image moloch
606 1 13

can you please give an example?
i mean i open my second zul page like this

Executions.createComponents("/WEB-INF/pages/zul/second.zul", null, map);

how to catch the onclose event when second.zul is closed?

link publish delete flag offensive edit

answered 2010-08-25 01:17:25 +0800

SimonPai gravatar image SimonPai
1696 1

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

link publish delete flag offensive edit

answered 2010-08-25 01:21:32 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

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

link publish delete flag offensive edit

answered 2010-08-25 01:56:36 +0800

moloch gravatar image moloch
606 1 13

hello, but works your way for 2 different composer stephan? i mean i want to know in composer 1 if zul page 2 is closed

link publish delete flag offensive edit

answered 2010-08-25 02:27:21 +0800

moloch gravatar image moloch
606 1 13

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

link publish delete flag offensive edit

answered 2010-09-06 07:03:11 +0800

moloch gravatar image moloch
606 1 13

updated 2010-09-06 07:19:53 +0800

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>

link publish delete flag offensive edit

answered 2010-09-07 03:34:10 +0800

moloch gravatar image moloch
606 1 13

thanks Stephan!

link publish delete flag offensive edit
Your reply
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

RSS

Stats

Asked: 2010-08-24 09:20:05 +0800

Seen: 2,040 times

Last updated: Sep 07 '10

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