Models subpackages in Play framework

♀尐吖头ヾ 提交于 2019-12-22 15:37:47

问题


The list of classes in my models package is getting pretty big and I want to refactor some of the classes into their own subpackage.

For instance, all forms go into models.forms, all users go into models.users, etc.

However if I now declare a template that takes a form:

@(myForm : Form[MyForm])

This gives me a not found: Type MyForm-error.

I've tried importing the class:

@import models.form.MyForm

but this doesn't make any difference.


回答1:


You need to fully-qualify MyForm in the first line of your view template when declaring the input parameters:

@(myForm : Form[models.common.MyForm])

It is indeed a bit unintuitive that the @import entry doesn't make any difference. Perhaps the way in which view templates are compiled means that custom types have to be fully qualified if they occur before the list of imports.



来源:https://stackoverflow.com/questions/16402582/models-subpackages-in-play-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!