Skip to content
pk11 edited this page Feb 10, 2012 · 7 revisions

Intercepting requests

Overriding onRequest

One another important aspect of the GlobalSettings class is that it provides a way to intercept requests and execute some business logic before a request is being dispatched to an Action.

Let's see this in action:

import play.*;

public class Global extends GlobalSettings {

@Override
public Action onRequest(Request request, Method actionMethod) {
   System.out.println("before each request..." + request.toString());
   return super.onRequest(request.actionMethod);
}

}

Of course it's also possible to intercept only a specific Action method. This can be achieved via Actions composition

Next: Testing your application

Clone this wiki locally