Is it possible in playframework to override the de

2019-05-29 01:24发布

问题:

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.