playframework 是否可以覆盖 CRUD 控制器中的默认保存操作并重定向到列表
我正在使用 Play 框架的出色的 CRUD 模块。问题是我想在保存我的对象之前进行一些特殊的处理和验证。所以我在 CRUD 控制器中创建了一个保存操作。到目前为止,一切都很好。但现在保存对象后,我想渲染对象列表,就像在覆盖其保存操作之前 CRUD 模块所做的那样。我该怎么做呢?
这是我的控制器:
package controllers.admin;
import java.util.List;
import models.Category;
import controllers.CRUD;
@CRUD.For(Category.class)
public class Categories extends CRUD {
public static void save(Long id, Category category) {
// Do my custom save process here
//Redirect to the list page like CRUD was doing before I created this save action
}
}
我尝试了不同的东西,例如 parent()
[已弃用],这不是我想要的。我尝试了 CRUD.list()
但我需要传递我没有的参数。我还尝试了 render(admin/Categories/List.html, ??????);
但我需要传递一个列表,但我不知道该怎么称呼它。
任何帮助将不胜感激。
I'm using Play framework's great crud module. The thing is I would like to do some special processing and validation before my object gets saved. So I created a save action in my CRUD controller. So far so good. But now after the object is saved I would like to render the list of objects just like the CRUD module was doing before I overrode its save action. How would I go about doing this?
Here is my controller:
package controllers.admin;
import java.util.List;
import models.Category;
import controllers.CRUD;
@CRUD.For(Category.class)
public class Categories extends CRUD {
public static void save(Long id, Category category) {
// Do my custom save process here
//Redirect to the list page like CRUD was doing before I created this save action
}
}
I tried different things like parent()
[Deprecated] not what I wanted. I tried CRUD.list()
but I need to pass parameters which I don't have. I also tried render(admin/Categories/List.html, ??????);
but I would need to pass a list and I don't know what to call it.
Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你走在正确的道路上。最后只需调用
redirect(request.controller + ".list");
它应该可以工作。You're on the right path. At the end just call
redirect(request.controller + ".list");
It should work.