ZK - Open Source Ajax Java FrameworkZK - Open Source Ajax Java Framework

doModal() question

jsantos
19 Dec 2008 15:16:25 GMT
19 Dec 2008 15:16:25 GMT

Hi, I want to create a modal window using just java code, not zul. I have an event listener. If I put this code inside it:

    Window w = (Window)Executions.createComponents("/design_drafts/testwindow.zul", null, null);
    w.doModal();

it works as expected. I get a little modal dialog with nothing inside.

but if I put this code inside the event listener:

	Window testWindow = new Window();
	testWindow.setWidth("100px");
	testWindow.setHeight("100px");
	testWindow.setTitle("title");
	testWindow.doModal();

I don't get the modal window to show.

for reference, the file /design_drafts/testwindow.zul is:

<window title="test" width="100px" height="100px">
</window>

so they should be equivalent. It is obvious that I am making a mistake, but I can't find out what it is. Can you help, please?

mjablonskiTop Contributor
19 Dec 2008 18:58:51 GMT
19 Dec 2008 18:58:51 GMT

You'll have to set a parent component (via window.setParent() or parent.appendChild(window)) for your Window to show up on your page.

Using Executions.createComponents(...) with a null-parent does this "automagically" for you:

Javadoc for Executions.createComponents()

HTH, Maik