After reading this post I was wondering what would be the best way to “superclass the controller” in my app.
I have several controllers that require different security, but, they use the same set of persisted variables in templates. Does this look like the right approach?
public class Globals extends Controller {
@Before
static void setGlobals() {
renderArgs.set("foo","bar");
}
}
Then annotate controllers @With interceptor
@With([Globals.class, mySecurity.class])
public class Application extends Controller {
// my methods
}
Cool?
Yes, using @With annotation is the way that play recommended. But you are free to use inheritance if no other side effect