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 identifiers


In JSF 2.0, a resource is an image, document, or some other digital asset. They are placed under the resources folder at the web context folder. In a Gradle or Maven project, a particular resource lives on the path, as shown:

src/main/webapp/resources/<RESOURCE-IDENTIFIER>

A resource may also be stored in a JAR file under the WEB-INF/lib folder:

src/main/webapp/WEB-INF/lib/<SOME>.jar

If the resource is stored in a JAR file, it must be located in the META-INF folder such that it can be located with the path:

META-INF/resources/<RESOURCE-IDENTIFIER>

RESOURCE-IDENTIFIER can be further divided into separate paths. The widest case supports full internalization. The constituent parts are as follows:

<RESOURCE-IDENTIFIER> := 
  [ <LOCALE-PREFIX> / ] [ <LIBRARY-NAME> / ] 
  [ <LIBRARY-VERSION> / ]
  <RESOURCE-NAME> [ / <RESOURCE-VERSION> ]

The subterms allow the resource identifiers to be easily identified and separated out.

The optional LOCALE-PREFIX term represents a locale such as en_gb (British English) or de (Germany).

The optional LIBRARY-NAME term specifies a library name. You can define the library name and use it in the JSF custom tags, as follows:

<h:outputStylesheet library="default" name="styles/app.css" />
<h:outputStylesheet library="admin" name="styles/app.css" />

The preceding example retrieves an application style sheet that is appropriate to the library. This helps to distinguish the different parts of your digital application. The resource lookup may resolve to the following:

<WEB-CONTEXT>/resources/en/default/1_0/styles/app.css
<WEB-CONTEXT>src/main/webapp/resources/en/admin/1_0/styles/app.css

These URLs map to the following source file assets in a conventional project:

src/main/webapp/resources/en/default/1_0/styles/app.css
src/main/webapp/resources/en/admin/1_0/styles/app.css

Developers do not specify the library version. Instead, the JSF Resource Lookup mechanism searches for the highest version files of the respective resources. The version number of the folder name must match the regex: \d_\d. Therefore, the version folder name 2_0 is greater than 1_5, which in turn, is higher than 1_0.