• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Facelets experts please advise!

 
Ranch Hand
Posts: 1419
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With Facelets, can I use templates for building new templates?

Can I partially instantiate a template to create a slightly more defined template?
Can I instantiate a template with another template (e.g. using one template to decorate another)?

Suppose A, B, C, D, ... are each sections of JSF mark-up, and each `_' indicates a template <ui:insert> region.

Example 1:

Suppose I create a template (A _ B _) that leaves room for two regions to be defined.
Obviously I could use it to compose JSF pages such as A C B D and or A E B F.

Could I compose it with just C, to result in a template that defines (A C B _)?
I would use that new template to define JSF pages such as:
A C B D,
A C B F,
A C B H,
etc.

Example 2:

Suppose I have a decorator template that defines (A _ B),
and another template that defines (C _ D _J),
could I compose them to produce a template that defines (A C _ D _ B)
-- with which I could then generate such JSF pages as:

A C E D F B,
A C G D H B

while still using the original two templates to produce

A J B

and

C K D L
 
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure I really understood that, but there is no theoretical limit to how you can define a View comprised of nested templates.

In practice, of course, it's best to keep it simple because otherwise the resulting visual display may offend the user's eyes. And of course, don't do circular references!
 
Frank Silbermann
Ranch Hand
Posts: 1419
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:I'm not sure I really understood that, but there is no theoretical limit to how you can define a View comprised of nested templates.

Is a template considered to be a kind of View when you say that -- or do you use "View" to refer only to a final JSF page definition?

In other words, suppose I have five templates that are each used hundreds of times. Among these uses, I have a dozen web pages, each of which nests the same five templates in the same way (but which differ as to the leaf facelets that are inserted).

Can I nest the five templates to create a sixth template (as distinct from nesting them in a page definition)?

That way, each of that dozen pages would just use that sixth template -- instead of constantly repeating a complex nesting.

(Sure, I could make that sixth template from scratch, but doing so would violate the DRY principle. So would repeating that same complex nesting.)
 
Tim Holloway
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For my purposes, the View is the entire web page and it may be composed of one or more sub-views. The sub-views may be complex controls, included templates, other Facelet composition templates, custom tags and so forth.

For the sake of visual sanity, I normally have 1 or a very small number of master templates which I then use to frame the more specific page content templates.
 
Frank Silbermann
Ranch Hand
Posts: 1419
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:For my purposes, the View is the entire web page and it may be composed of one or more sub-views. The sub-views may be complex controls, included templates, other Facelet composition templates, custom tags and so forth.

For the sake of visual sanity, I normally have 1 or a very small number of master templates which I then use to frame the more specific page content templates.

And does that mean one can or cannot use templates in the definition of other templates?
 
Tim Holloway
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nest templates all you want.
reply
    Bookmark Topic Watch Topic
  • New Topic