-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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>
win.onClose();
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>
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
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
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
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.
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
Asked: 2009-12-28 13:50:12 +0800
Seen: 2,870 times
Last updated: Jan 17 '12