Is it possible in playframework to override the default save action in the CRUD controller and redirect to list after

旧时模样 提交于 2019-12-10 10:57:46

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/4415627/is-it-possible-in-playframework-to-override-the-default-save-action-in-the-crud

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