[2.0] Block page rendering

64 views
Skip to first unread message

YoZH

unread,
Sep 28, 2012, 5:19:25 AM9/28/12
to play-fr...@googlegroups.com
Hello!

What is a must have approach when designing an application with easily distinctive zones?
For example, I have 4 zones in my app: "Header", which may contain some static info (app logo, etc), top-level navigator, login information, "Left" which contain low-level navigation, some options, may be tag cloud, or survey, etc
"Center" zone, which is for current page content, and "Footer" zone, which may contain static and non-static content.

I'm new to Play, and cannot figure out, how to design controllers and templates, and to compose them so, that I could make one change in, for example, top zone content rendering, including change in types of data which is rendered and would not be forced to change dozens of other views which, for example, render Center zone, etc., passing new parameters to main template which in its turn will include other templates etc.

TY in advance

James Roper

unread,
Sep 28, 2012, 6:07:18 AM9/28/12
to play-fr...@googlegroups.com
Are you using Java or Scala?

YoZH

unread,
Sep 28, 2012, 6:24:22 AM9/28/12
to play-fr...@googlegroups.com
Sorry, Java

пятница, 28 сентября 2012 г., 14:07:18 UTC+4 пользователь James Roper написал:

James Roper

unread,
Sep 28, 2012, 8:07:42 AM9/28/12
to play-fr...@googlegroups.com
Currently there are two "nice" (or not so nice) ways to do this:

1) Have a god object, that you pass into every template, and provides all the data needed by each part.  You can change the types of data in that template without changing what gets passed through.
2) Write static methods, that look up the data you need, and call them from the templates.

YoZH

unread,
Sep 28, 2012, 8:11:13 AM9/28/12
to play-fr...@googlegroups.com
Kinda non-system approach, imo, but  tyvm
Any more suggestions?

пятница, 28 сентября 2012 г., 16:07:42 UTC+4 пользователь James Roper написал:

Mathias Clerc

unread,
Oct 1, 2012, 2:11:01 AM10/1/12
to play-fr...@googlegroups.com
Create "header", "left" and "footer" each in their own template.
Create a "main" template which will include and set those 3 parts as
well as the page content.

For each page of your website, you can then wrap the content with your
main template like:
@main(/* you can pass your page dependent parameters here */){
<!-- Your page html code -->
}

Same idea as behind the helloworld sample (hello.scala.html and
index.scala.html have their html wrapped by the 'main' template
containing the common layout).


2012/9/28 YoZH <dsaka...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/play-framework/-/1KrAHnd5_9MJ.
>
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to
> play-framewor...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/play-framework?hl=en.
Reply all
Reply to author
Forward
0 new messages