JavaServer Faces (JSF ) 2.x has introduced several new features, such as integrated Facelets, implicit navigation, conditional navigation, preemptive navigation, bean validation, view parameters, client behaviors, new scopes (view, flash, and custom), configuration annotations, composite components, Resource Handler API, support for Ajax, and new event handling and exception handling features.
WildFly 8.x supports JSF 2.2, the latest version of JSF. JSF 2.2 has introduced new features of convenient HTML5 markup, Resource Library Contracts, Face Flows, and stateless views. JSF 2.2 support is added to a project with a Maven dependency. In this chapter, we will develop a JSF 2.x Facelets application in Eclipse, build and package the application with Maven, and deploy the application to WildFly 8.1. We will run the application in WildFly 8.1 to demonstrate the use of Facelets in a web application. Facelets is the default View Declaration Language (VDL) in JSF 2.x, replacing JSP as the default VDL. This chapter has the following sections:
We need to install the following software:
wildfly-8.1.0.Final.zip
from http://wildfly.org/downloads/Set the environment variables JAVA_HOME
, JBOSS_HOME
, MAVEN_HOME
, and MYSQL_HOME
. Add %JAVA_HOME%/bin
, %MAVEN_HOME%/bin
, %JBOSS_HOME%/bin
, and %MYSQL_HOME%/bin
to the PATH
environment variable.
Create a WildFly 8.1.0 runtime as discussed in Chapter 1, Getting Started with EJB 3.x. Create a MySQL database CATALOG
with the following SQL script:
CREATE TABLE CATALOG(CatalogId INTEGER PRIMARY KEY, Journal VARCHAR(25), Publisher VARCHAR(25), Edition VARCHAR(25), Title Varchar(45), Author Varchar(25)); INSERT INTO CATALOG VALUES('1', 'Oracle Magazine', 'Oracle Publishing', 'Nov-Dec 2004', 'Database Resource Manager', 'Kimberly Floss'), INSERT INTO CATALOG VALUES('2', 'Oracle Magazine', 'Oracle Publishing', 'Nov-Dec 2004', 'From ADF UIX to JSF', 'Jonas Jacobi'), INSERT INTO CATALOG VALUES('3', 'Oracle Magazine', 'Oracle Publishing', 'March-April 2005', 'Starting with Oracle ADF ', 'Steve Muench'),
Run the script in the MySQL 5.6 command-line client. The database table, Catalog
, gets created. The output from the preceding script is shown in the following screenshot:
We also need to configure a data source for MySQL database. The procedure to configure a MySQL data source was discussed in Chapter 1, Getting Started with EJB 3.x, and will not be repeated in this chapter.