0

Listbox server push

asked 2010-02-09 05:47:32 +0800

tabsuny gravatar image tabsuny
102

Dear All,

程式码大意:zul文件
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit"?>
<?page title="DataScreen" contentType="text/html;charset=utf-8"?>
<zk>
<zscript src="data.zs">
import com.serverPush;
</zscript>
<window id = "window" onCreate="serverPush.start(idevent)">
<listbox id="idevent" visible="true" width="100%" mold="paging" pageSize="52" >
<listhead width="100%" sizable="true">
<listheader label="label1" width="10%" />
<listheader label="label2" width="25%" sort="auto" />
<listheader label="label3" width="25%" />
<listheader label="label4" width="40%" />
</listhead>
</listbox>
</window>
</zk>

改变浏览器窗口大小(放缩),Listheaders没有根据当前窗口的大小去调节。

有哪位大虾遇到过这个问题吗?

delete flag offensive retag edit

4 Replies

Sort by » oldest newest

answered 2010-02-09 06:57:40 +0800

tabsuny gravatar image tabsuny
102

updated 2010-02-09 19:09:09 +0800

不好意思,我发现问题所在了。当我改变窗口大小时 ServerPush的时间设置的过长了。。。没有刷新过来。
ZUL:
<?page title="new page title" contentType="text/html;charset=UTF-8"?>
<zk>
<zscript>
import demo.ServerPush;
ServerPush thread;

void startServerpush(){
desktop.enableServerPush(true);
thread= new ServerPush(idevent);
thread.start();
}
void stopServerpush(){
desktop. enableServerPush(false);
thread.setDone();
}
</zscript>
<window title=" godood">
<button label="Stop Push" onClick="stopServerpush()"/>
</window>

<window id = "window" onCreate="startServerpush()">
<listbox id="idevent" visible="true" width="100%" mold="paging" pageSize="52" >
<listhead width="100%" sizable="true">
<listheader label="label1" width="10%" />
<listheader label="label2" width="25%" sort="auto" />
<listheader label="label3" width="25%" />
<listheader label="label4" width="40%" />
</listhead>
</listbox>
</window>
</zk>

ServerPush.java:

package demo;


import org.zkoss.zk.ui.Desktop;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.Listcell;
import org.zkoss.lang.Threads;
import org.zkoss.zk.ui.Executions;


public class ServerPush extends Thread {
private final Desktop _desktop;
private final Listbox _info;
private int _cnt;
private boolean _ceased;
public ServerPush(Listbox info) {
_desktop = info.getDesktop();
_info = info;
}
public void run() {
try {
while (!_ceased) {
Threads.sleep(10000); //Update each 10 seconds

if (_info.getDesktop() == null
|| !_desktop.isServerPushEnabled())
{
_desktop.enableServerPush(false);
Executions.deactivate(_desktop);
System.out.println("break");
break;
}

Executions.activate(_desktop);
try {
for(int i = 0; i < 10; i++)
{
Listitem item = new Listitem();
item.setParent(_info);
for(int j = 0; j < 4; j++)
{
Listcell cell = new Listcell();
cell.setLabel("cell" + j);
cell.setParent(item);
}
}

} catch (RuntimeException ex) {
throw ex;
} catch (Error ex) {
throw ex;
} finally {
Executions.deactivate(_desktop);
}
}
} catch (InterruptedException ex) {
}
}
public void setDone(){
_ceased = true;
System.out.println("true");
}
}


怎么能让它及时的改变大小呢?
您有没有好的想法?

link publish delete flag offensive edit

answered 2010-02-09 19:25:38 +0800

adam4891288 gravatar image adam4891288
657 1 5

给listbox加入 fixedLayout="true" 属性即可

link publish delete flag offensive edit

answered 2010-02-09 19:59:42 +0800

tabsuny gravatar image tabsuny
102

Dear adam,
ooo~~
正是我想要的效果。
非常感谢!

Tab

link publish delete flag offensive edit

answered 2010-02-10 21:26:42 +0800

adam4891288 gravatar image adam4891288
657 1 5

哈,不用谢~

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: 2010-02-09 05:47:32 +0800

Seen: 455 times

Last updated: Feb 10 '10

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