-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3535981
By: devorior
I put timer tag in order to refresh xHTML page in zk:zscript tag, but it doesn't do a refresh. What's the matter with ir?
<?taglib uri="/WEB-INF/tld/zul/core.dsp.tld" prefix="u" ?> <html xmlns:zk="http://www.potix.com/2005/zk">
<head>
<title>ZHTML Demo</title>
</head>
<body>
<table width="100%" cellSpacing="1" cellPadding="2" border="1" align="right"
valign="top">
<tr valign="middle">
<td align="center" width="30%" class="status_header"><font class="left">Resource</font></td>
<td align="center" class="status_header"><font class="left">Status</font></td>
<td align="center" class="status_header"><font class="left">Elapsed time</font></td>
</tr>
<tr id="tr">
<zk:zscript>
for (int i = 0; i < 3; i++) {
Component td = new Td();
String id = "td" + new Integer(i).toString();
td.setId(id);
td.setParent(tr);
new Text("cell" + new Date().getTime()).setParent(td);
}
</zk:zscript>
</tr>
</table>
<zk:zscript>
<timer id="timer" delay="500" repeats="true" />
</zk:zscript>
</body>
</html>
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3536029
By: henrichen
Hi, devorior,
Only java code (or, more correctly, Beanshell code) can be put inside the zscript tag. You don't put a xul component timer inside the zscript.
In your case, you can either new the Timer directly within the zscript. Or, you can declare the xul namespace, and declare the timer directly.
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3536043
By: devorior
I'm newbie in ZK and XUL. Could you give me some code for example. I have tried to create Timer in zscript tag, but it doesn't work also. I wrote new Timer("500"), but it didn't help. Please, write some code for both cases.
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3536068
By: tomyeh
Timer is a component though it is not visible, so you have to add it to a page by calling setParent.
Also, you have to listen to the onTimer event.
To manually create a timer, here is an example.
<window id="wnd" title="Timer demo" border="normal">
<label id="now"/>
<separator bar="true"/>
<button label="Stops timer" onClick="timer.stop()"/>
<button label="Starts timer" onClick="timer.start()"/> <zscript> Timer tm = new Timer(1000); tm.setRepeats(true); tm.setParent(wnd);
private class TimerListener implements EventListener {
public boolean isAsap() {
return true;
}
public void onEvent(Event event) throws UiException {
event.target.getFellow("now").setValue(new Date().toString());
}
}
tm.addEventListener("onTimer", new TimerListener()); </zscript> </window>
On the other hand, you could declare it in ZUML. Following is the equivalent
example:
<window title="Timer demo" border="normal">
<label id="now"/>
<timer id="timer" delay="1000" repeats="true"
onTimer="now.setValue(new Date().toString())"/>
<separator bar="true"/>
<button label="Stops timer" onClick="timer.stop()"/>
<button label="Starts timer" onClick="timer.start()"/> </window>
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3536083
By: devorior
maybe the problem is in file extension. I'm using .zhtml extension in order to use common HTML tags. When I have tried your last example in .zhtml page I saw JavaScript error that object "timer" not found. What extension should I use to work with both HTML and XUL tags?
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3536089
By: tomyeh
Refer to the user guide (especially, "ZUML and Namespace", "ZUL or ZHTML").
The concept is ZK uses the extension to decide the default component set. For referencing components from other set, you have to specify XML namespace.
Asked: 2006-01-23 06:25:14 +0800
Seen: 1,169 times
Last updated: Jan 23 '06