0

how to access the value from zscript to javascript

asked 2015-05-18 10:08:23 +0800

79pk gravatar image 79pk
3 1

how to access the value from zscript to javascript

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-05-19 02:23:21 +0800

echarish gravatar image echarish flag of Japan
1809 7
http://jp.linkedin.com/in...

updated 2015-05-19 02:31:38 +0800

Hello

ZSCRIPT vaiables are available through EL expressions so you can get myArrayList which is a List in Java by using $[myArrayList] expression.

<zk><zscript>
<![CDATA[
myArrayList = new ArrayList();
for(int i = 0;i < 2;i++)
    myArrayList.add(i);]]>  </zscript> // javascript starts from here <script defer="true">
//Accessing zscript variable in javascript
var arrayListElements= ${myArrayList};
for (var i =0,len=arrayListElements.length; i != len; i++)
    alert(i);  </script></zk>

Sorry for bad formatting, i am not able to enter pre-formatted code here so entered it like this :(

if you need more details, please follow this document http://books.zkoss.org/wiki/ZKComponentReference/Essential_Components/Script

and here is a example for you http://www.zkoss.org/zkdemo/effects/upload_effect

Harish

link publish delete flag offensive edit
Your answer
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
1 follower

RSS

Stats

Asked: 2015-05-18 10:08:23 +0800

Seen: 29 times

Last updated: May 19 '15

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