Files   Prepare   Run   Troubleshooting   Related Topics 

JavaServer Faces Basic

 

About the Example

JavaServer Faces technology allows developers to...

  1. assemble reusable UI components in a page
  2. connect these components to an application data source
  3. wire client-generated events to server-side event handlers

This example demonstrates usage of the JSF Managed Bean.

CustomerSearch.jsp includes JSF components for...

  1. getting the user's input
  2. submitting a search request
  3. rendering a search result

demoDataBaseHelper and customerSearchBean are JSF managed beans defined in...

../WEB-INF/faces-config.xml

After you run the example, a customer search form will be displayed in the browser. To submit a search request, type a whole or partial customer name and click the "Search" button; the example invokes the method...

customerSearchBean.findCustomers

The demoDataBaseHelper object connects to a demo database and executes a SQL statement to fetch the records. These fetched records are used to populate a list of Customer objects, which is in turn returned to customerSearchBean. Finally, the JSF components in CustomerSearch.jsp render the list of customers to the browser.

The CustomerSearch.jsp JSP also demonstrates how to use JavaServer Pages Standard Tag Library (JSTL) tags with JSF components.


 

Files Used in the Example

Directory Location...

WL_HOME/wlserver_10.3/samples/server/examples/webapp/jsf/basic/

File Description
application.xml J2EE standard enterprise application deployment descriptor.
build.xml Ant build file that contains targets for building and running the example.
ExamplesFooter.jsp Contains the Example Footer.
ExamplesHeader.jsp Contains the Example Header.
CustomerSearch.jsp Contains JSF components.
Customer.java Model class for a customer.
CustomerSearchBean.java JSF Managed Bean class that handles the request data and events submitted by the form in CustomerSearch.jsp.
DataBaseHelper.java JSF Managed Bean class used to execute the SQL statement.
DataSourceListener.java ServletContextListener which sets the DataSource in ServletContext while the example is deploying. The DataSource is used in the example to access the demonstration database.
faces-config.xml JSF configuration file.
web.xml Web application deployment descriptor.
weblogic.xml Oracle WebLogic Server-specific Web application deployment descriptor.

 

Prepare the Example

 

Prerequisites

Before working with this example:

  1. Install Oracle WebLogic Server, including the examples.

  2. Start the Examples server.

  3. Set up the environment.

This example uses tables in the PointBase demo database. The database should already contain the necessary tables and sample data.

 

Configure Oracle WebLogic Server

It is assumed in this example that the JSF 1.2 implementation has been installed as a shared library in the Examples server. If this is not true, install...

WLS_HOME/common/deployable-libraries/jsf-1.2.war

...as a shared library named jsf.

The example uses JDBC connections using the examples-dataSource-demoPool JDBC data source in the wl_server domain. You can view the data source configuration in the Administration Console:

  1. Open the Administration Console.

  2. In the Domain Structure tree, select...

    Services | JDBC | Data Sources | examples-dataSource-demoPool

 

Build, deploy, and run the example

To build and deploy, set the environment, and then run...

cd SAMPLES_HOME\server\examples\src\examples\webapp\jsf\basic
ant build
ant deploy
ant run

The Ant command uses...

SAMPLES_HOME\server\examples\src\examples\webapp\jsf\basic\build.xml

A browser window will open. In the browser, search for customer records using the names listed in the following table:

Name of Address City State Zip Area Phone
Jackson 100 First St. Pleasantville CA 95404 707 555-1234
Elliott Arbor Lane, #3 Centre Town CA 96539 415 787-5467
Avery 14 Main Arthur CA 97675 510 834-7476

 

Troubleshooting


 

Related Topics

  1. Developing Web Applications, Servlets, and JSPs for Oracle WebLogic Server
  2. JSF Technology
  3. Developing Applications for Oracle WebLogic Server