Autocomplete for Play 2.0 views paths in Scala con

2019-05-06 04:31发布

问题:

This is a visual reference to the google group discussion: https://groups.google.com/group/play-framework/browse_thread/thread/14660fd7056d577e/a3afb4ca06d25ce5#a3afb4ca06d25ce5

So, I'm simply trying to add some verbosity to views:

When I reference either of the files, or try to, in the Scala controller, based on the example provided in the Google Group, I get an error:

What gives?

回答1:

Disclaimer: I'm not a Eclipse user, just created and imported blank Play's project to check this issue! I had no time to test Eclipse configs, just imported as descriped at Play's docs. Maybe it is some way to better configuration, but you need search for it yourself :)

I wouldn't blame Play, it does its job properly, otherwise it wouldn't compile at all. As I wrote in Google Group's topic you need to place your view in package: /views/nested/index.scala.html (of course nested is just a some name it can be whatever else), then you can catch it with: Ok(views.html.nested.index())

In Eclipse:

  1. in Package Explorer click views package with: right mouse button > New > Package and write package's name views.nested or views.one or something else, even it could be: views.nested.one.two.three
  2. Add new view into this package myNewView.scala.html
  3. Run any request in browser (to let the Play compile new views), optionally you can run Play with command play ~run so it will compile your new or changed views right after saving in IDE.
  4. in Eclipse menu choose Project > Clean.... De facto, that's the clue, I'm not quite sure why this cleaning is required as Play compiles everything properly, read the disclaimer at the beginning.
  5. From now your Eclipse will see this new view(s)

Screenshot