-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello, i have a doubt, i'm using a library from the client to draw a chart in the HTML page. The chart is created from Javascript code. I need return from server dynamic javascript and i need know how i can this it do from ZKoss Framework. I attach the code:
...
< ![CDATA[
for (var i = 0; i <= 30; i += 1)
{
d1.push([i,10]);
d2.push([i, Math.pow(0.08*i, 3)]);
}
]] >
...
I need push into "d1" and "d2" dynamic variables values from de server.
Can anyone help me?
Thanks!
Hernan
herman, please post again with some code
/costas
Hi Hernan,
As an additional information, if you are working in ZUML (.zul file), you can directly include JavaScript in you page, using the script component.
like this:
<script type="text/javascript" defer="true">
<![CDATA[
var d1 =[]; var d2 =[]; for(i=0; i<30;i++){
d1.push([i,10]); d2.push([i, Math.pow(0.08*i,3)]); }
]]>
</script>
Edit: To call JS from the server side, you can use Clients.evalJavaScript() http://books.zkoss.org/wiki/ZKDeveloper'sReference/UIPatterns/UsefulJava_Utilities#evalJavaScript
Zk can let you transfer values from the server to the client in many ways, but the correct one on your situation depends on your design. Based on your sample, I understand that you are creating 2 arrays of 30 values, in the variable d1 & d2. How are you trying to use those variables?
Please post relevant server and client code.
The code:
"
...
< ![CDATA[
for (var i = 0; i <= 30; i += 0.1)
{
d1.push([i,10]);
d2.push([i, Math.pow(0.08*i, 3)]);
}
]] > "
I need
Thanks! Yes, i need send those variables from server to client where both of them are arrays. How can i doing it? For example (from server):
Clients.evalJavaScript("test(1,2)");
How can i send some variables as arguments in the "evalJavaScript" method. Thanks again! Bye
I could resolve it on this way:
...
ArrayList<string> s = new ArrayList<string>();
_s.add("1");
_s.add("5");
Clients.evalJavaScript("test("+s+")");
...
And the server call the function with the sent parameter.
Thanks!
Asked: 2015-08-14 14:24:37 +0800
Seen: 31 times
Last updated: Aug 18 '15
Facing issue in masking on phone [closed]
coerceFromString_ override no longer works from 6.5.1 [closed]
Execute Javascript on component visible
Is there a way to resolve view model properties as input to client side javascripts?
scrollbar listner for 2 grid [closed]
Theme javascript wpd file not found