Search code examples
playframework

How play framework's Results class is imported for different methods like ok(), status() etc


I am new to play framework and basically understands Java well, but once i see this code the only conclusion i can draw regarding "Results" class is imported automatically, but decompiled .class file from .jar generated by sbt "package" states otherwise.

    package controllers;


import play.mvc.Controller;
import play.mvc.Result;

/**
 * This controller contains an action to handle HTTP requests
 * to the application's home page.
 */
public class HomeController extends Controller {

    /**
     * An action that renders an HTML page with a welcome message.
     * The configuration in the <code>routes</code> file means that
     * this method will be called when the application receives a
     * <code>GET</code> request with a path of <code>/</code>.
     */
    public Result index() {
        String str="";
        return ok(views.html.index.render());
    }
    
    public Result explore() {
        return ok(views.html.explore.render());
    }
    
    public Result tutorial() {
        return ok(views.html.tutorial.render());
    }

}

using version 2.8.8


Solution

  • You can use play.mvc.Results methods inside play.mvc.Controller because it extends Results class.

    Constroller class is declared this way:

    public abstract class Controller extends Results implements Status, HeaderNames {
    
    ...
    
    }