Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Playframework - Eclipse can't detect a new template [duplicate]

Possible Duplicate:
How to make Eclipse see the changes in Play! compiled templates?

I am doing my first steps with the Play! Framework and I run into some problems. I can create and eclipsify a project without any problems.

Now if I add a new view, for example 'sometest.scala.html' and I try to use it in the 'Application' Eclipse marks this file as an error.

package controllers;

import play.*;
import play.mvc.*;


import views.html.*;;

public class Application extends Controller {



public static Result index() {
    return ok(sometest.render("test"));  // this line is marked red
  }

}

Eclipse marks sometest red, even if it works. If I go to localhost:9000, I can see my changes.

My view folder looks like this:

app
--views
----index.scala.html
----main.scala.html
----sometest.scala.html

I created sometest as a html file and set the file name to .scala.html

Simple solution:

run your app with

$ cd myapp
$ play
$ run

go to your webrwoser and type: localhost:9000

create a new .scala.html file in your views folder.

Refresh your website at localhost:9000

Done.

like image 647
Maik Klein Avatar asked Jun 08 '26 10:06

Maik Klein


2 Answers

I run this problem daily while using eclipse, BUT with eclipse this works pretty well already.. run play with play ~run command instead and after that you sometimes only need to select your project in eclipse - right click and refresh, boom = errors gone.

like image 125
Mauno Vähä Avatar answered Jun 10 '26 22:06

Mauno Vähä


After creating new view you have to first run the app in the browser, to allow Play to compile it as a Scala class (which are recognized by IDE) then you need to click menu -> Project Build all, then Eclipse will refresh the view.

Optionally you can try IntelliJ which doesn't require any additional actions to start recognizing the freshly created classes.

like image 31
biesior Avatar answered Jun 10 '26 22:06

biesior