0

Problem with nested oppup windows

asked 2011-09-02 23:27:18 +0800

ajaidka gravatar image ajaidka
196 4

I am facing problem with nested popup windows. When I do an escape on child, onCancel of parent is called, hence both windows get closed.
I just want to close child first and on 2nd escape parent should be closed.

this is how i am creating popup windows.
Window popupWin = (Window) Executions.getCurrent().createComponents("edit_product_options_group_popup.zul", self, arg);
popupWin.doModal();

Any idea??

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2011-09-05 20:15:40 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

Hi ajaidka,
can you provide a reproducing sample?

link publish delete flag offensive edit

answered 2011-09-06 02:54:04 +0800

ajaidka gravatar image ajaidka
196 4

index.zul

<?page title="Auto Generated index.zul"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit"?>
<window title="Hello World!!" border="normal" width="200px" apply="com.test.popup.MainCtrl">
<button id="openPopup" label="Open Popup"></button>
</window>

MainCtrl.java
public class MainCtrl extends GenericForwardComposer {

private Button openPopup;

public void setOpenPopup(Button openPopup) {
this.openPopup = openPopup;
openPopup.addEventListener("onClick", new EventListener() {

@Override
public void onEvent(Event arg0) throws Exception {
Window popupWin = (Window) Executions.getCurrent().createComponents("/popup_win.zul", self, arg);
try {
popupWin.doModal();
} catch (SuspendNotAllowedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}


}

popup_win.zul
<?page title="First Popup" contentType="text/html;charset=UTF-8"?>
<zk>
<window title="Parent Popup" border="normal" apply="com.test.popup.PopupWinViewCtrl" onCancel="self.detach();">
New Content Here!

<button id="openChildPopup" label="Open Child Popup"></button>

</window>
</zk>


PopupWinViewCtrl .java
public class PopupWinViewCtrl extends GenericForwardComposer {

private Button openChildPopup;

public void setOpenChildPopup(Button openChildPopup) {
this.openChildPopup = openChildPopup;

openChildPopup.addEventListener("onClick", new EventListener() {

@Override
public void onEvent(Event arg0) throws Exception {
Window popupWin = (Window) Executions.getCurrent().createComponents("/child_popup_win.zul", self, arg);
try {
popupWin.doModal();
} catch (SuspendNotAllowedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});

}

}

child_popup_win.zul
<?page title="First Popup" contentType="text/html;charset=UTF-8"?>
<zk>
<window title="Parent Popup" border="normal" closable="true" onCancel="self.detach();">
Press Escape!
</window>
</zk>


escape on child_popup_win will close it's parent too.

link publish delete flag offensive edit

answered 2011-09-07 14:14:35 +0800

ajaidka gravatar image ajaidka
196 4

Can I just avoid window to be closed when I do Escape?

Aashu

link publish delete flag offensive edit

answered 2011-09-14 03:37:37 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

I have tested the following sample with ZK 5.0.7.1
it works fine

<zk>
	<window title="Win 1" border="normal" width="200px" mode="modal" onCancel="System.out.println(1);self.detach();">
			<window title="Win 2" border="normal"  mode="modal"  onCancel="System.out.println(2);self.detach();">
				<textbox/>
			</window>
		<textbox/>
	</window>
</zk>

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: 2011-09-02 23:27:18 +0800

Seen: 804 times

Last updated: Sep 14 '11

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