Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you use DTOs in Play Framework scala templates?

I'm playing around with a Play application and I want to pass a list of DTOs from the controller to the template:@(dtos: List[MyDTO])

My first instinct is to add the DTO class to a new package named dtos, but if I do that I get an error when running the app: not found: type MyDTO. I tried adding @import dtos.MyDTO in the template, but I still get the error. If i put the DTO in the model package it works just fine, but I don't want to do that as I don't want that to interfere with Ebean table generation and evolutions.

So what packages are seen by default in the template, and how can I make my class visible to the template from a new package?

like image 650
Andrei Fierbinteanu Avatar asked Dec 13 '25 10:12

Andrei Fierbinteanu


1 Answers

add this to your Build.scala:

PlayProject(...) settings(
  ...
  templatesImport ++= Seq(
    "com.company.dto", "com.company.useful", ...
  )
)
like image 101
virtualeyes Avatar answered Dec 16 '25 11:12

virtualeyes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!