Icefaces Facelets to get a template effect

I am planning to make it dynamic, but haven’t yet done the hands on.


include icefaces-facelets.jar

and put the following into web.xml


This tells JSF to assume a prefix of jspx, which the Facelet’s rendered can interpret. Facelets can use many other parameters depending on your application.

put the following into faces-config.xml




tell JSF about the Facelets view handler. This is a plug-in that handles the Render Response and Restore View phases of the JSF request-processing life cycle.

Template Idea

And then comes the confusing part, I can’t understand this after reading the document twice. I have to jump into the source and do some hands on to figure this out. I think I have a better way to present it. This may be my wrong intepretation.

You need three things.

1. a jsp that load the template

2. a jspx which is the template

3. some jspx which are components you put inside the template.

1. load template

  • <ui:composition> – This is a templating tag that wraps content to be included in another facelet. Any content outside the composition tag will be ignored by the Facelets view handler.
  • <ui:define> – This tag is a templating tag that defines named content to be inserted into a template.


            <ui:composition template="mainTemplate.jspx">
<ui:define name="faceletHeader">
<meta http-equiv="Content-Type"
content="text/html; charset=utf-8"></meta>
<ice:outputText value="Facelet Dynamic Include Tutorial"/>
<link href="./xmlhttp/css/xp/xp.css" rel="stylesheet" type="text/css"/>

2. The template

  • <ui:insert>– A templating tag that declares a named content element to be defined by another Facelet. Used effectively with the ui:define tag.
  • <ui:include>– A server-side include tag for Facelets. It simply includes the document pointed to by the “src” attribute as part of the current JSF page.


<ui:insert name="content">
<ui:include src="./content-facelet.jspx" />

3. Contents

just icefaces jspx that you normally write.


The confusing part is when you load the template, you will have two way to actually put content inside <ui:insert>.

1. use <ui:define> inside “template load” to put content directly into it.

2. use <ui:include> inside “template” to reference a jspx.

And if I am not getting it wrong, any content inside <ui:insert> which is not <ui:include> will be replace by <ui:define> stuff.

I will update this post when I get the dynamic reference content work.

Have fun~