Play! framework. create a new view
Asked Answered
P

4

6

I created a new project using the play console
now, by default I got in my views directory two files:

main.scala.html   
index.scala.html 

I want to add a new view file. I call it "forums.scala.html"
now, I know that in order to render a view you need to do this:

views.html.forums.render("Forums");

the problem is that the intellisense doesn't recognize "forums"
but index and main it does recognize.
I've noticed those files:

class_managed/views.html/index.class
class_managed/views.html/main.class

but there is no forums.class so I suspect this is the problem.
I tried to build the project, but it didn't help.
so, what is the solution?

thanks

Penny answered 30/7, 2012 at 19:24 Comment(0)
T
9

Your new views are compiled to managed sources after next browser hit if you are using play run for starting Play in dev mode.

If you'll use play ~run it will try to compile it as soon at it will recognize change in the file.

Finally if you started your app in production mode ie. via play start you have to stop it with ctrl+c and run again. Anyway, developing application in production mode is just a bad idea :)

Depending on your IDE most probably you'll need to refresh file structure to allow it find freshly created managed sources.

Turrell answered 30/7, 2012 at 19:35 Comment(1)
no. it didn't help. I ran the application with this command: "play ~run", but still the forums.scala.html didn't compiled to the managed sources.Penny
M
6

right click on ther project and click refresh, that worked for me - found it in another thread.

Misbegotten answered 21/5, 2013 at 11:9 Comment(0)
P
2

Found the solution.
running "compile" command did the work.
I understood that intelliJ do it auto, so I will probably use it instead of eclipse.

cheers!

Penny answered 31/7, 2012 at 10:0 Comment(1)
But you clicked 'compile' in the IDE ? Normally Play's console compiles files beside the used software (if running) so the application should work properly even if IDE shows it as unresolved parts (until next manual refreshing). And yes IntelliJ watches the resources and recognizes them ASAPTurrell
S
1

If you want to program in scala, my recommendation is to forget about intellisense. Eclipses scala-ide is quite buggy, dont know about netbeans. And because of nonstandard layout of play2 application, non std development tools (play console), it becames even more handy to use simple text redactor (like sublime or textmate) with good old open-folder-as-project feature.

Selfreliant answered 30/7, 2012 at 20:38 Comment(1)
You should try IntelliJ Idea. In current version (11) it starts to recognize freshly compiled view-classes just a few seconds after compilation (there is small lag, however it doesn't required to perform any action from the user). New version that will be available at te end of this year (12 - Leda) probably will work even better, as there is planned special support for Play 2.xTurrell

© 2022 - 2024 — McMap. All rights reserved.