sending a method to client
7 Feb 2012 04:44:21 GMT
10 Feb 2012 06:37:48 GMT
10 Feb 2012 06:37:48 GMT
TestComposer.java
index.zul
Hi raviteja,
You can 'run script by server' or 'put script to client' as the sample:
TestComposer.java
package j3j22jdv$v1;import org.zkoss.zk.ui.util.*;
import org.zkoss.zul.*;public class TestComposer extends GenericForwardComposer{
Button btnOne;
Button btuTwo;
public void onClick$btnOne () {
runScriptFromServer ();
}
public void onClick$btnTwo () {
putScriptToClient ();
}
public void runScriptFromServer () {
String script = "zk.log(' run script from server');";
Clients.evalJavaScript (script);
}
public void putScriptToClient () {
String script = "zk.log(' the script from server to client');";
Clients.evalJavaScript ("window.scriptFromServer = function () {"+script+"};");
}
}
index.zul
<zk>
<script>
setInterval (function () {
if (scriptFromServer) {
zk.log(' run the script at client: ');
scriptFromServer();
}
}, 3000);
</script>
<window apply="j3j22jdv$v1.TestComposer">
<button id="btnOne" label="Run Script From Server" />
<button id="btnTwo" label="Get Script From Server to Client" />
</window>
</zk>
Regards,
ben
ZK - Open Source Ajax Java Framework
Hai Every one,
As i am new to zk i have one problem
i have one method which is written below and i have written this in method in Calendar Controller class which extends genericforward composer . Now I want to send it to the client.
private void execToolTipJScript(){
Script script = new Script();
String code = "setTimeout(function(){$('.z-calevent').each(function(){"+
"$('.z-calevent-resizer', this).remove();"+
"var timeSpan = $('.z-calevent-text', this).html();"+
"$('.z-calevent-header', this).html(timeSpan.substring(timeSpan.indexOf('<%#>')));"+
"var tooltip = $('.z-calevent-header', this).html() + ': ' + $('.z-calevent-text', this).html();"+
"$(this).attr('title', tooltip);"+
"});},100);";
script.setContent(code);
script.setPage(page);
}