Im fairly new to using Play! and to using scala, I cant figure out how I pass in a custom class type to a view in play! 2.2.x.
What I want to accomplish is:
Have a base class (such as)
public abstract class Category {
String Name;
String Info;
String Link;
}
Pass a number of these to the view:
@(categories: Array[Category])
@main{
{
//In here, iterate over all the categories and display their information.
}
With use of a controller
public static Result categories() {
Category[] categoriesArray = new Category[3];
categoriesArray[0] = new blahCategory(...);
categoriesArray[1] = new fooCategory(...);
categoriesArray[2] = new someCategory(...);
return ok(categories.render( categoriesArray ));
}
I have the abstract class under a folder called "model" and the scala.html files in the "view" folder.
However when going to the url, play! errors on:
not found: type Category
In /home/me/MySite/app/views/categories.scala.html at line 0.
1 @(categories: Array[Category])
2
3 @main{
4 @heading()
5 {
6 }