playframework - Play framework template parameter - pass a subclass -
i have view template accepts following parameter:
@(groups: list[models.groups.academicgroup] i have academic group class:
@mappedsuperclass public abstract class academicgroup extends model and subclass this:
@entity public class schoolclass extends academicgroup calling view template within template works:
@views.html.panels.groups(schoolclasses.asinstanceof[java.util.list[models.groups.academicgroup]]) what isn't working, passing sublass directly via controller:
public static result schoolclasses() { list<schoolclass> schoolclasses = schoolclass.find.all(); return ok(groups.render(schoolclasses)); } with approach, error message:
the method render(list<academicgroup>) in type groups not applicable arguments (list<schoolclass>) typecasting list doesn't work. there missing or there way implicitely accept subclass template parameter can java generics:
list<? extends academicgroup>
thanks serejja!
passing list[_ <: academicgroup] works!
this equal list<? extends academicgroup>
adding + sign carsten mentioned leads compiler error
Comments
Post a Comment