0

Dialog / Close event

asked 2009-12-28 13:50:12 +0800

haddorp gravatar image haddorp
81 2 3

Using the ZK Live Demo I've registered an onClose event to a modal window. The event is called if clicking the small x in the right corner. This is fine.

But if pressing the OK button of hello-template.zul nothing happens. How to close the window without skipping the registered onClose event? Or are there other events to be registered for the OK button?

Thanks, JC


<window title="Modal Dialog" border="normal">
<button label="Hello.doModal">
<attribute name="onClick">{
final Window win = (Window) Executions.createComponents(
"/userguide/layout/hello-template.zul", null, null);
win.setMaximizable(true);
win.addEventListener("onClose",
new EventListener() {
public void onEvent(Event event) throws Exception {
Messagebox.show("Window has been closed", "Information", Messagebox.OK, Messagebox.INFORMATION);
}
});
win.doModal();
}</attribute>
</button>
</window>

delete flag offensive retag edit

13 Replies

Sort by ยป oldest newest

answered 2009-12-28 15:37:50 +0800

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

updated 2009-12-28 15:38:34 +0800

win.onClose();

link publish delete flag offensive edit

answered 2009-12-28 15:56:13 +0800

haddorp gravatar image haddorp
81 2 3

As far as I could see until now win.onClose() does not work - same as win.detach().

But I will try again to be sure that both methods are acting the same way.

link publish delete flag offensive edit

answered 2009-12-29 15:02:56 +0800

haddorp gravatar image haddorp
81 2 3

I've tried it again... And it's the same... The x button is working - if using win.doClose or win.detach nothing happens.

Below I've added my full sample code. I'm using 5.0 RC2. The message box is not shown if pressing the OK button to close the modal window.
The behavior is the same when using win.doModal or win.doHighlighted. This seems to be correct.


main.zul
<window title="Modal Dialog" border="normal">
<button label="Hello.doModal">
<attribute name="onClick">{
final Window win = (Window) Executions.createComponents("hello-template.zul", null, null);
win.setMaximizable(true);
win.addEventListener("onClose", new EventListener() {
public void onEvent(Event event) throws Exception {
Messagebox.show("Window has been closed", "Information", Messagebox.OK, Messagebox.INFORMATION);
}
});
win.doModal();
}</attribute>
</button>
</window>


hello-template.zul
<window id="win" title="1st window" border="normal" width="200px" closable="true">
Hello, World!
<button label="OK" onClick="win.onClose()"/>
</window>

link publish delete flag offensive edit

answered 2010-01-07 04:17:10 +0800

haddorp gravatar image haddorp
81 2 3

Any news/ideas on my question?

link publish delete flag offensive edit

answered 2010-01-07 05:22:40 +0800

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

updated 2010-01-07 05:25:25 +0800

Hmmmm, seems like a bug in zk5.

I have tested yet your code on zk 3.6.3 and by clicking the OK button of the hello-template.zul this window closes correct.

Stephan

link publish delete flag offensive edit

answered 2010-01-07 11:58:34 +0800

haddorp gravatar image haddorp
81 2 3

Yes, the window closes correctly; but the event is not fired. Means the message box is only shown when pressing the x button; not when pressing OK.

Perhaps I should do a re-test with ZK 3.6.3 as well.

Cheers, JC

link publish delete flag offensive edit

answered 2010-01-07 15:31:28 +0800

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

Hmmm, i don't understand you right.

.detach is not an event. It decouples the component from the DOM.

Can you explain what you will do?

Stephan

link publish delete flag offensive edit

answered 2010-01-08 03:37:49 +0800

haddorp gravatar image haddorp
81 2 3

In our use case we have a list filled by data binding. To change a row the user can open the entry in a modal dialog. After editing is done the dialog should close and the list should be updated.

For the update of the list an event would be fine that is called after the dialog has been closed. Maybe my approach isn't perfect... Please let me know.

It's no problem to open a dialog. And it's no problem to close this via a save / cancel button. But haven't found a way for triggering the update in the main window.

Hope it more clear now... Sorry, if my request has been confusing.

link publish delete flag offensive edit

answered 2010-01-08 09:30:33 +0800

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

updated 2010-01-08 09:32:38 +0800

But haven't found a way for triggering the update in the main window
.

That's easy. You can not only overhanded the casted listitems object to your dialog for editing. But you can overhanded the controller self or it's listbox per param as a map to the opened Dialog too.
Than you can do what you want in the dialog and when needed you have access to the underlaying window.
You can see many samples about that in our sample application here . The sources are opended.

best
Stephan

link publish delete flag offensive edit

answered 2010-01-08 16:17:34 +0800

haddorp gravatar image haddorp
81 2 3

Thanks! Your sample application shows many interesting coding ideas :-)

Regards, JC

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: 2009-12-28 13:50:12 +0800

Seen: 2,870 times

Last updated: Jan 17 '12

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