CRUD 模块和嵌套模型和/或控制器
是否可以将实体放入嵌套文件夹/包中并仍然使用 CRUD 模块进行基本管理?
我正在使用 YABE 应用程序,playframework 1.2.4。
我创建了另一个名为“Page”的实体,并尝试将其放入所有文件夹中名为“cms”的子文件夹中,如下所示:
models
-- cms
-- Page.java
etc.
YABE 实体的现有链接是这样创建的:
<a href="@{Users.list()}">Users</a>
生成路由 admin /users 并引导您到 CRUD 生成的页面
,但如果您放置类似的内容,例如还在嵌套文件夹内创建控制器:
<a href="@{cms.Pages.list()}">Pages</a>
生成像这样的链接 cms.pages/list 并引导您到“不发现”
即使我将控制器放在控制器根文件夹中也不起作用,显然是因为 CRUD 模块无法找到模型类,因为它位于子文件夹中。
当页面相关的类位于控制器和模型的根目录中时,一切正常,但我想要类似“包”的东西。
我做错了什么?
这样的事情可能吗?
如果我将所有内容移至单独的模块中,它会起作用吗?
Is it possible to put Entity inside of a nested folder/package and still use CRUD module for basic administration?
I'm using YABE app, playframework 1.2.4.
I created another Entity called "Page" and I tried to put it in subfolder called "cms" in all folders like this:
models
-- cms
-- Page.java
etc.
Existing link for YABE Entities is created like this:
<a href="@{Users.list()}">Users</a>
which generates route admin/users and leads you to a CRUD generated page
but if you put something like this, e.g. also create controller inside nested folder:
<a href="@{cms.Pages.list()}">Pages</a>
generates link like this cms.pages/list and leads you to "Not found"
Even if I put controller in a controllers root folder doesn't work, obviously because CRUD module can't find model class because it's in subfolder.
When Page related classes are in root of controllers and models, everything works fine, but I want something like "packages" here.
What am I doing wrong?
Is something like this possible?
Will it work if I move everything to a separate module?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是可能的。然而,我发现将实体的 CRUD 模型保留在不同的包中会使事情变得更加复杂,并且不会增加太多价值。
无论如何,请确保您的控制器使用 @CRUD.for 注释,以便它们知道要管理哪个实体:
如果您需要将视图放在子包中,请播放 crud:ov --template cms/Users/list 将无法按预期工作,除非您可以使用以下内容破解 crud Commands.py:
我无法确定,但我认为您可能需要使用以下内容重新定义路由规则:
It is possible. However I found that keeping the CRUD models for entities in a different package made things a little more complicated and did not add that much value.
Anyway make sure your controllers use the @CRUD.for annotation so they know which entity to manage:
If you need to place your views in a subpackage, play crud:ov --template cms/Users/list will not work as expected except if you hack the crud commands.py with something like:
I can't remember for sure but I think you might need to redefine your routing rules with something like: