3

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.

Community
  • 1
  • 1
Maik Klein
  • 15,548
  • 27
  • 101
  • 197

2 Answers2

7

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.

Mauno Vähä
  • 9,688
  • 3
  • 33
  • 54
5

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.

biesior
  • 55,576
  • 10
  • 125
  • 182
  • 1
    I am not sure what happened, but I created a new project and now eclipse automatically refreshes the new scala classes and it works just fine. – Maik Klein Jul 31 '12 at 12:00
  • So try to realize :) although I don't need Eclipse support I'm pretty sure that most of people will be interesting about this knowledge, Thanx for info. – biesior Jul 31 '12 at 12:05
  • 1
    I had the same problem and Build All was disabled. I simply refreshed the project and errors are gone! Right click the project and Refresh. – Madhan Ganesh Nov 14 '13 at 03:10