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

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -