Book Image

Mastering JavaServer Faces 2.2

By : Anghel Leonard
Book Image

Mastering JavaServer Faces 2.2

By: Anghel Leonard

Overview of this book

Table of Contents (20 chapters)
Mastering JavaServer Faces 2.2
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
The JSF Life Cycle
Index

Passing parameters via <ui:param>


The <ui:param> tag is a tag handler that is capable of sending parameters to an included file or to a template. A quick example will make you understand how <ui:param> works. In the following code, we are in the template client, index.xhtml, and we send a parameter to the template file, layout.xhtml:

<ui:composition template="template/layout.xhtml">  
  <ui:param name="playername" value="Rafael " />
</ui:composition>

We can also access this parameter in layout.xhtml using its name via EL. We can do that anywhere in the template file; for example, we can use this parameter for creating a new parameter to be sent to an included file, in this case, to the contentDefault.xhtml file, as shown in the following code:

<div id="content">
  <ui:insert name="content">
    <ui:include src="/template/default/contentDefault.xhtml">
      <ui:param name="playernamesurname" value="#{playername} Nadal" />
    <...