0

Strange: window.setClosable(true) moves the window to the lower left, you have to scroll the browser

asked 2008-10-22 19:10:20 +0800

hkn gravatar image hkn
246 3

Hello
I use a mode="overlapped" window to show the user some background activities and
when the background process finishes, it sets the window to be closable so that the
little cross on the upper right corner appears.
That happens and also the window disappears, but it is not hidden or closed.
When scrolling down the browser window the window will reappear. It has been moved
to the lower left corner out of the visible part of the browser.

When calling setClosable(true) from the main window the window stays where it is and the
cross to close it appears - as expected.

Is it a bug ??

zk 3.5.1
java 1.6
tomcat 6

Here is some sample code to reproduce the effect. Start is m1.zul, opens m2.zul by button click.
m2.zul makes use of GenericForwardComposer, Server Push and starts a background thread.

Maybe one of you gurus has an idea !

thx & best regards

Horst

// MAIN WINDOW
file: m1.zul

<?page id="page1" title=" New ZUL Title" cacheable="false"
language="xul/html" zscriptLanguage="Java" contentType="text/html;charset=UTF-8"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit"?>
<zk xmlns="http://www.zkoss.org/2005/zul"
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd">
<window id="main" title="Main" border="normal" width="700px"
height="500px" position="center,top" mode="overlapped">
<button id="btStart" label="Start">
<attribute name="onClick"><![CDATA[
Window win2 = Executions.createComponents("/m2.zul", null, null);
]]></attribute>
</button>
<button id="closable" label="enable closable (does not move the window)" onClick="win2.setClosable(true)"></button>
</window>
</zk>


// LOG WINDOW, DISPLAYS BACKGROUND ACTIVITIES
file: m2.zul

<?page id="page2" title="Show background activities" cacheable="false"
language="xul/html" zscriptLanguage="Java" contentType="text/html;charset=UTF-8"?>
<zk xmlns="http://www.zkoss.org/2005/zul"
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd">
<window id="win2" title="2nd Win: Show background activities" border="normal" width="600px"
closable="false" mode="overlapped" position="center,center"
height="250px" apply="Crtl">
<listbox id="lb" width="550px" height="180px" />
</window>
</zk>


//Controller, initiates the background thread

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Button;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.Window;
public class Crtl extends GenericForwardComposer {
// zul objects
protected Window win2;
protected Button bt;
protected Listbox lb;
// dummy background process (Thread)
class Background extends Thread {
public void run() {
Calendar cal = Calendar.getInstance();
DateFormat dtf = new SimpleDateFormat("dd.MM.yy hh:mm:ss");
Listitem itm;
for (int i = 1; i < 10; i++) {
try {
Executions.activate(desktop);
itm = new Listitem(dtf.format(cal.getTime()) + "item " + i);
itm.setParent(lb);
Executions.deactivate(desktop);
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
try {
Executions.activate(desktop);
itm = new Listitem(dtf.format(cal.getTime()) + "DONE !");
// STRANGE BEHAVIOUR, MOVES THE WINDOW OUT OF SCREEN !
// **************************************************
win2.setClosable(true);
Executions.deactivate(desktop);
desktop.enableServerPush(false);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
// Start background process
public void onCreate$win2(Event ev) {
desktop.enableServerPush(true);
Background bg = new Background();
// start thread
bg.start();
}
}

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2008-10-27 02:55:17 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

Hi,

I tried your example, and it seems to be OK.
Please see the video here

I didn't see the nested window moves to lower left corner.
It is a correct behavior when you invoke the setClosable() method, the window will invalidate itself, so you can see it disappears, and then appears.

link publish delete flag offensive edit

answered 2008-10-27 10:17:46 +0800

hkn gravatar image hkn
246 3

Hi,

yes - what you show works, I know. Just click the start and wait.
Please see this video http://www.screencast.com/t/xJa7ud3N
The Background thread sets closable at its end and then it happens.

Kind regards

Horst

link publish delete flag offensive edit

answered 2008-10-28 06:26:58 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

Hi,

This bug is relative to this one

Please follow it.

link publish delete flag offensive edit

answered 2008-10-28 08:35:51 +0800

hkn gravatar image hkn
246 3

Hello jumperchen,

I cannot see that as ServerPush and Activate/Deactivate works fine.
Just remove/comment "win2.setClosable(true)" and all is as expected.
So it is just a new little bug I think.

In my app as a workaround I now show a "close" button when the thread ends running.

/Horst

link publish delete flag offensive edit

answered 2008-10-29 01:03:04 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

Hi,

The bug is caused by the fact that the first request of Serverpush does not send the unsent information to server, then the window was gone.
And the stop function of Serverpush in your example also broke, so I suggest you can follow the bug, which will be fixed together.

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: 2008-10-22 19:10:20 +0800

Seen: 257 times

Last updated: Oct 29 '08

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