Play framework problem with form

Posted on

Question :

Introduction

I’m starting to develop with the Play Framework. I’m making an ALL list template with it.

Problem

When I am instantiating my form in the controller it returns me the following error:

Would anyone know what the problem is?

Controller (Application.java)

package controllers;

import play.*;
import play.mvc.*;
import play.data.*;
import play.data.Form;

import views.html.*;

import models.*;

public class Application extends Controller {
    static Form<Task> taskForm = form(Task.class);

    public static Result index() {
        return redirect(routes.Application.tasks());
    }

    public static Result tasks() {
        return TODO;
    }

    public static Result newTask() {
        return TODO;
    }

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

}

    

Answer :

Change:

form(Task.class);

To:

Form.form(Task.class);

Or if you prefer, statically import Form methods like this:

import static play.data.Form.*;

And continue using it the way you did.

    

Place Form.form(Task.class); instead of error.

In this link you have an example of a CRUD with master-detail: Play Crud Master-Detail

    

Leave a Reply

Your email address will not be published. Required fields are marked *