[ 2.0 ] - views with nested folders erroring, Scala

388 views
Skip to first unread message

franklovecchio

unread,
May 4, 2012, 1:44:09 PM5/4/12
to play-framework
Not sure if I'm completely missing something here.

If I have a view at:

/app/views/index.scala.html

It's easy to reference in the controller as:

Ok(views.html.index())

But if I have a view at:

/app/views.nested/index.scala.html

I get an error when trying to reference in the controller:

Ok(views.nested.html.index())


How do I do this?

sun

unread,
May 4, 2012, 3:06:17 PM5/4/12
to play-framework
Ok(views.html.nested.index())

franklovecchio

unread,
May 4, 2012, 3:26:59 PM5/4/12
to play-framework
I tried that! It doesn't work.

Typing "views." brings up autocomplete for "nested", but past that,
nothing.

On May 4, 1:06 pm, sun <goo...@suncom.de> wrote:
> Ok(views.html.nested.index())

franklovecchio

unread,
May 4, 2012, 3:27:59 PM5/4/12
to play-framework
It also brings up autocomplete for "html" after "views.", but none of
the combinations work. I can only get it to work with a views/
index.scala.html file. Bug?

sun

unread,
May 4, 2012, 4:07:03 PM5/4/12
to play-framework
Autocomplete? Do you use an IDE?

biesior

unread,
May 4, 2012, 4:52:36 PM5/4/12
to play-fr...@googlegroups.com
You can figure it out quite fast with good IDE.

your nested view has to be placed in:

/views/nested/index.scala.html

than you can catch it with:

return ok(views.html.nested.index.render());


additionally
As I wrote somewhere before it's better idea to prefix view's name with package name to allow easier importing these views and avoid namespace conflicts:

/views/nested/nestedIndex.scala.html

then import:

import views.html.nested.*;

and render (you can be sure that will not be mistaken with /views/index.scala.html)

return ok(nestedIndex.render());

franklovecchio

unread,
May 4, 2012, 10:24:59 PM5/4/12
to play-framework
Thanks! I am using Eclipse...I'm pretty sure play 2.0 is still a
little buggy.

On May 4, 2:52 pm, biesior <bies...@gmail.com> wrote:
> You can figure it out quite fast with good IDE.
>
> your nested view has to be placed in:
>
> /views/nested/index.scala.html
>
> than you can catch it with:
>
> return ok(views.html.nested.index.render());
>
> *additionally *

franklovecchio

unread,
May 4, 2012, 11:02:45 PM5/4/12
to play-framework
Actually, no. It doesn't work. I've attached some images:

http://stackoverflow.com/questions/10458461/play-2-0-templating-nested-views-wtf

sun

unread,
May 5, 2012, 1:27:21 AM5/5/12
to play-framework
So the Eclipse autocomplete usually does not pick up view changes
imediately, ok.
But when you issue "play run" the template should be picked up
correctly.
So, yes, it seems the Eclipse integration is not perfect yet, but Play
itself should run fine.

biesior

unread,
May 5, 2012, 8:11:38 AM5/5/12
to play-fr...@googlegroups.com
Check the answer at SO, generally I wouldn't call it is Play's bug, I don't know the Eclipse enough however Play app is working with the method I've described before and also Idea has no problems, in Eclipse I found that's required to perform the Project > Clean command, but maybe it's configuration topic. However as you can see at the screenshot - it works.

Check newest IntelliJ Idea (Ultimate edition) - they have fully functional trial so you can decide if it is worth of money.
Reply all
Reply to author
Forward
0 new messages