在playframework中有可能覆盖CRUD控制器中的默认保存操作,并重定向到列表之后 [英] Is it possible in playframework to override the default save action in the CRUD controller and redirect to list after

查看:325
本文介绍了在playframework中有可能覆盖CRUD控制器中的默认保存操作,并重定向到列表之后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Play框架的伟大crud模块。事情是我想在我的对象被保存之前做一些特殊的处理和验证。所以我在我的CRUD控制器中创建了一个保存操作。到现在为止还挺好。但现在在对象被保存后,我想渲染对象列表,就像CRUD模块在我覆盖它的保存操作之前做的。

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?

这是我的控制器:

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() [Deprecated ]不是我想要的。我尝试了 CRUD.list()但我需要传递我没有的参数。我也试过 render(admin / Categories / List.html,??????); 但我需要传递一个列表,我不知道什么

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.

任何帮助将不胜感激。

推荐答案

在正确的道路上。最后只需调用 redirect(request.controller +.list); 它应该工作。

You're on the right path. At the end just call redirect(request.controller + ".list"); It should work.

这篇关于在playframework中有可能覆盖CRUD控制器中的默认保存操作,并重定向到列表之后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆