How could I create non-action function at a Play 2 controller? Is any way to create utilities functions for controller?
public class Register extends Controller {
@BodyParser.Of(BodyParser.FormUrlEncoded.class)
public static Result registerByForm() {
.......
}
// this is utility function
private static User getFacebookIdByToken(String fbToken) {
FacebookClient facebookClient = new DefaultFacebookClient(fbToken);
User user = facebookClient.fetchObject("me", User.class);
return user;
}
}
In Play 1.0 there was no way to distinguish a
static void foo()non-action and an action, hence the@Utilannotation. My guess would be that Play 2.0 can distinguish, based on the return type, if a method is an action or not, which should only get you into trouble if you, for whatever reason, want to create aResultreturning method in aControllerthat is not an Action.