Book Image

Digital Java EE 7 Web Application Development

By : Peter Pilgrim
Book Image

Digital Java EE 7 Web Application Development

By: Peter Pilgrim

Overview of this book

Digital Java EE 7 presents you with an opportunity to master writing great enterprise web software using the Java EE 7 platform with the modern approach to digital service standards. You will first learn about the lifecycle and phases of JavaServer Faces, become completely proficient with different validation models and schemes, and then find out exactly how to apply AJAX validations and requests. Next, you will touch base with JSF in order to understand how relevant CDI scopes work. Later, you’ll discover how to add finesse and pizzazz to your digital work in order to improve the design of your e-commerce application. Finally, you will deep dive into AngularJS development in order to keep pace with other popular choices, such as Backbone and Ember JS. By the end of this thorough guide, you’ll have polished your skills on the Digital Java EE 7 platform and be able to creat exiting web application.
Table of Contents (21 chapters)
Digital Java EE 7 Web Application Development
Credits
About the Author
Acknowledgment
About the Reviewers
www.PacktPub.com
Preface
Index

Resource Library Contracts


JSF 2.2 introduces the concept of Resource Library Contracts, which allows a digital developer to organize a library of assets and templates in a reusable set of resources. A resource library contract must reside in the contracts directory folder in the application's web context root. In the standard Maven or Gradle build convention, this folder is src/main/webapp/contracts. Each subfolder in the contracts folder represents a named resource contract.

The setup for the Chapter 6, JSF Flows and Finesse used a layout for the Resource Library Contracts, as follows:

/src/main/webapp/contracts/

/src/main/webapp/contracts/default/

/src/main/webapp/contracts/default/template.xhtml

/src/main/webapp/contracts/default/styles/app.css

/src/main/webapp/contracts/default/images/

/src/main/webapp/contracts/victoria/

/src/main/webapp/contracts/victoria/template.xhtml

/src/main/webapp/contracts/victoria/styles/app.css

/src/main/webapp/contracts/victoria/images/

Every contract must have at least one declared template.xhtml file. A contract may have more than one template for its own customization. The declared template has at least one declared insertion point, which is defined as the <ui:insert> tag. A template usually relies on the digital assets, and these are known as declared resources.

Contracts can be packaged in the JAR files for a customer's use. A resource library contract must be placed in the META-INF/contracts folder of the JAR file. So, we could repackage the flow examples in the following layout:

META-INF/contracts/

META-INF/contracts/default/javax.faces.contract.xml

META-INF/contracts/default/template.xhtml

META-INF/contracts/default/styles/app.css

META-INF/contracts/default/images/

META-INF/contracts/victoria/

META-INF/contracts/victoria/javax.faces.contract.xml

META-INF/contracts/victoria/template.xhtml

META-INF/contracts/victoria/styles/app.css

META-INF/contracts/victoria/images/

We will need to add an empty marker file to each contract, javax.faces.contract.xml. The reference for this filename is found in the static string: javax.faces.application.ResourceHandler.RESOURCE_CONTRACT_XML.