Compile error in scala template while passing an arraylist: Not found value

playframework, scala

Solution

In Parameter lists of Scala templates you have to use the (a) fully qualified class name or (b) you import them in your Build.scala.

(a)

@(profiles: List[models.com.contactmanager.Profile])

(b)

//Play 2.2
val main = PlayProject(…).settings(
  templatesImport += "models.com.contactmanager.Profile"
)

For Play 2.3 the API changed: https://www.playframework.com/documentation/2.3.x/ScalaTemplates#Import-statements

TwirlKeys.templateImports += "models.com.contactmanager.Profile"

Problem

I am trying to pass an arraylist to a scala template from a play controller. In my controller ``` List<Profile> profiles = Profile.findAll(); return ok(contacts.render(profiles)); ``` In the template contacts.scala.html ``` @import models.com.contactmanager.Profile @(profiles: List[Profile]) ``` I am getting the error: ``` not found: value profiles [error] ``` for line ``` @(profiles: List[Profile]) ```

Original source