faruk.kuscan
faruk.kuscan

Reputation: 499

render function doesn't exist in play framework 2.0.2?

I downloaded and installed play framework 2.0.2 and then created a project. I eclipsified the project and opened it in eclipse.

I have a class called Application which extends Controller class. In most examples around the web, I see controllers like the following.

public class Application extends Controller {
    public static void index() {
        render(arg0,arg1,...);
    }

    public static void tasks() {
         render(arg0,arg1,...);
    }

    public static void newTask() {
         render(arg0,arg1,...);
    }

    public static void deleteTask(Long id) {
        render(arg0,arg1,...);
    }
}

However in my default application, I can only do the following. I don't know how to do the previous one.

public class Application extends Controller {
    public static Result index() {
        return ok("Hello World!");
    }

    public static Result tasks() {
         return ok(indexabc.render("hello world"));
    }

    public static Result newTask() {
         return TODO;
    }

    public static Result deleteTask(Long id) {
        return TODO;
    }
}

In my code when I try to replace "Result" return type with "void", there is no problem. However, when I want to call "render()" method with some parameters, that method doesn't exist. I can't find a way for how to call render function.

Upvotes: 3

Views: 938

Answers (1)

Codemwnci
Codemwnci

Reputation: 54894

The examples you are seeing around the Web are for Play 1.x, and the version you have got in your Controller is for Play 2.x.

Play 1 used render(), play 2 returns a Result object, which is created from calling the ok() method or a number of other methods.

You have 2 options at this point. Download Play 1.2.5 (current stable release) and use the examples you have found, or use the Play 2.x documentation and search for Play 2.x examples.

Upvotes: 3

Related Questions