playframework - how to create an array and reuse in scala template play framework 2? -


i need create array in 1 of index.scala.html. later want use array store values.

i want achieve following index.scala.html

@import scala._  @myarray = @{arraylist()}; 

and getting error saying

not found value @myarray

if above problem resolved want reuser @myarray add string values. how can ?

thanks

you can declare , use new variable this:

@import java.util._  @defining(new arraylist[string]()) { myarray =>     @{       myarray.add("1")       myarray.add("2")       myarray.add("3")       ""     }      @for(s <- myarray) {         @s     } } 

but don't recommend because makes template code mess. in controller.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -