-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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没有根据当前窗口的大小去调节。
有哪位大虾遇到过这个问题吗?
不好意思,我发现问题所在了。当我改变窗口大小时 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");
}
}
怎么能让它及时的改变大小呢?
您有没有好的想法?
给listbox加入 fixedLayout="true" 属性即可
哈,不用谢~
Asked: 2010-02-09 05:47:32 +0800
Seen: 455 times
Last updated: Feb 10 '10