6 Using JSF and JSTL

Learn how to use JavaServer Faces (JSF) and JSP Standard Tag Library (JSTL) with WebLogic Server.

This chapter includes the following sections:

Using JSF and JSTL With Web Applications

JSF and JSTL are an integral part of Java EE and, as such, are incorporated directly into WebLogic Server. All Java EE technologies are present on the WebLogic Server classpath. No additional configuration is required to use any of the Java EE technologies in your applications. Applications deployed to WebLogic Server can seamlessly make use of JSF 2.3 and JSTL 1.2 without requiring you to deploy and reference separate shared libraries.

The Java EE API JAR file is included in WL_HOME\wlserver\server\lib\javax.javaee-api.jar, where WL_HOME represents the top-level installation directory for WebLogic Server.

For information about referencing these shared libraries with your Web applications, see Creating Shared Java EE Libraries and Optional Packages in Developing Applications for Oracle WebLogic Server.

JavaServer Faces (JSF)

JavaServer Faces technology simplifies building user interfaces for JavaServer applications. Developers of various skill levels can quickly build Web applications by: assembling reusable UI components in a page, connecting these components to an application data source, and wiring client-generated events to server-side event handlers.

WebLogic Server supports the JSF 2.3 specification at https://jcp.org/en/jsr/detail?id=372. The themes for this release are better integration with other APIs and leverage of Java SE 8 features. WebLogic Server support includes:
  • Better CDI integration; a CDI-compatible @ManagedProperty annotation.
  • Better WebSocket integration; direct support for WebSockets using the new <f:websocket> tag.
  • Ajax method invocation.
  • Class-level bean validation using the new <f:validateWholeBean> tag.
  • Java date and time support.
  • Enhanced component search expression framework.

These features are described in detail in the Java EE Tutorial at https://javaee.github.io/tutorial/toc.html and in "What's new in JSF 2.3?" at https://javaserverfaces.github.io/whats-new-in-jsf23.html.

If you selected to install the server examples with your WebLogic Server installation, the sample application demonstrates the following key features of JSF 2.3:

  • Ajax method invocation using the new <h:commandScript> component
  • CDI converter
  • Iterable h:dataTable
  • CDI for evaluation of JSF-specific EL implicit Objects
  • CDI injection
  • New Java date and time
  • @ManagedProperty
  • Iterable ui:repeat
  • Class-level bean validation using f:validateWholeBean
  • CDI validator
  • WebSocket using f:websocket

The JSF 2.3 examples are located in the ORACLE_HOME\wlserver\samples\server\examples\src\examples\javaee8\jsf directory, where ORACLE_HOME represents the directory in which you installed WebLogic Server.

For more information about the WebLogic Server code examples, see Sample Applications and Code Examples in Understanding Oracle WebLogic Server.

JavaServer Pages Standard Tag Libraries (JSTL)

The JavaServer Pages Standard Tag Library (JSTL) encapsulates as simple tags the core functionality common to many Web applications. JSTL has support for common, structural tasks, such as:

  • Iteration and conditionals

  • Tags for manipulating XML documents

  • Internationalization tags

  • SQL tags

JSTL also provides a framework for integrating existing custom tags with JSTL tags.

WebLogic Server supports the JSTL 1.2 specification at http://jcp.org/en/jsr/detail?id=52. For general information about JSTL technology, see the product overview at http://www.oracle.com/technetwork/java/jstl-137486.html.

JSF Backward Compatibility

JSF is developed using the Java Community Process, and therefore, should be backward compatible through JSF 1.0 when compiling and at runtime.

Applications built for JSF 1.2 should run unmodified on WebLogic Server 12.2.1, assuming you remove any bundled JSF implementation from the application configuration. If you follow this process and applications do not run, WebLogic Server provides JSF and JSTL libraries that can be deployed and referenced by applications. See the following sections:

Note:

The jsf-2.0.war deployable library, included in WebLogic Server, is empty, as applications built for JSF 2.0 will continue to run unmodified using the built-in JSF 2.2 implementation of WebLogic Server 12.2.1.

WebLogic Server includes the empty jsf-2.0.war library to avoid any software that depends on its existence. You can leave references to the library unchanged without harm. However, Oracle recommends removing any references to this empty library, as these references add no functionality.

Deploying JSF and JSTL Libraries

Note:

In this release of WebLogic Server, you can deploy JSF 2.3 and JSTL 1.2 applications directly. For backward compatibility, use the following directions when deploying JSF 1.x and JSTL 1.1 applications.

When deploying JSF 1.2 applications, use the JSF and JSTL libraries which are provided as Web application libraries. You must deploy the libraries before deploying the Web application that is using JSF 1.2 or JSTL functionality. You can deploy the libraries using the WebLogic Server Administration Console or the command-line weblogic.Deployer utility.

Here's an example of deploying a JSF 1.2 library using the weblogic.Deployer command-line:

  java weblogic.Deployer -adminurl t3://localhost:7001 
  -user weblogic -password weblogic
  -deploy -library
   d:/oracle_home/wlserver/common/deployable-libraries/jsf-1.2.war

This command deploys the JSF 1.2 library using the default library-name, specification-version and implementation-version defined by the MANIFEST.MF in the library.

After a library is deployed, the extension-name, specification-version and implementation-version of the library can be found in the WebLogic Server Administration Console. This information can also be found in the MANIFEST.MF file of the library WAR file.

For more information about deploying a Web module, see Preparing Applications and Modules for Deployment in Deploying Applications to Oracle WebLogic Server.

Referencing a JSF or JSTL Library

To reference a JSF or JSTL library, a standard Web application can define a <library-ref> descriptor in the application's weblogic.xml file. Here is an example:

  <library-ref>
    <library-name>jsf</library-name>
    <specification-version>1.2</specification-version>
    <implementation-version>1.2</implementation-version>
    <exact-match>false</exact-match>
  </library-ref>

For more information on referencing a Web application library, see Creating Shared Java EE Libraries and Optional Packages in Developing Applications for Oracle WebLogic Server.