How to assign or initialize a Java array to Javascript array, without using JSP? -


i working in play framework , need use java array inside javascript.

i tried following -

var jsarray = ${javaarray}; 

where javaarray array in java controller, being rendered html view.

but, not working. can please me on this?

don't forget you're not passing variables... you're writing javascript code

so, have make array rendering nicely javascript

var jsarray = [%{javaarray.eachwithindex{it,idx->                  }%                  ${it}${(idx<javaarray.size()-1)?",":""}                  %{                  }                  }%] 

use fits template engine. have iterate through array prints out values on view

ps : i've used groovy notation...


Comments

Popular posts from this blog

haskell - Using filter on an item in a list? -

c# - When does PreApplicationStartMethod actually get triggered to run? -

tomcat6 - Exception when stopping container for a with Spring + Quartz + Tomcat web application -