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 thetables/defaultTablePage.xhtml
page - The
tableGreen
contract is associated with thegreenTablePage.xhtml
page - The
tableBlue
contract is associated with theblueTablePage.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...