Download presentation
Presentation is loading. Please wait.
1
IS-907 Java EE Templating
2
Templates When an application contains several pages with similar structure, duplication of code can be avoided through the use of templates The template defines the structure of the page with named parts The template may specify default content for each part Facelets which use the template must specify the named parts Default content is used for unspecified parts Even Åby Larsen IS-102 Introduksjon
3
Defining templates The template is an ordinary facelet, except ui:insert tags are used to specify replacable parts: <html xmlns=" xmlns:h=" xmlns:ui=" <h:head> <title><ui:insert name="title" /></title> <h:outputStylesheet library="css" name="is907.css" /> </h:head> <h:body> <div id="heading" class="heading"> <ui:insert name="heading” /> </div> ... Even Åby Larsen IS-102 Introduksjon
4
Defining default content
The ui:include tag is used to include default content from other files: <div id="sidebar" class="menu"> <ui:insert name="sidebar"> <ui:include src="/views/common/sidebar.xhtml" /> </ui:insert> </div> Even Åby Larsen IS-102 Introduksjon
5
Using templates <html xmlns=" xmlns:f=" xmlns:h=" xmlns:ui=" <h:head> <title>IGNORED</title> </h:head> <h:body> <ui:composition template="/views/templates/layout.xhtml"> <ui:define name="title">IS-907 Netshop - Price List</ui:define> <ui:define name="content"> <h1>Price List</h1> ... </ui:define> </ui:composition> Even Åby Larsen IS-102 Introduksjon
6
Using templates Facelets refer to templates with a ui:composition tag
and specify the parts with ui:define tags Only the contents of the ui:composition tag are used the rest of the file is ignored the structure of the page is taken from the template Included files (e.g. default parts) are treated the same way: Even Åby Larsen IS-102 Introduksjon
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.