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

Configuring contracts in XML


Contracts can be associated with the JSF pages, as you saw in the previous sections. As an alternative, we can accomplish the same thing by configuring contracts in the faces-config.xml file. For example, let's suppose that we have three contracts: default, tableGreen, and tableBlue. Their association with different pages is as follows:

  • The default contract is associated with the tables/defaultTablePage.xhtml page

  • The tableGreen contract is associated with the greenTablePage.xhtml page

  • The tableBlue contract is associated with the blueTablePage.xhtml page

In faces-config.xml, we can do these associations using a few tags—the following example code speaks for itself:

<application>
  <resource-library-contracts>
    <contract-mapping>
      <url-pattern>/blueTablePage.xhtml</url-pattern>
      <contracts>tableBlue</contracts>
    </contract-mapping>
    <contract-mapping>
      <url-pattern>/greenTablePage...