Files Prepare Run Troubleshooting Related Topics
JavaServer Faces technology allows developers to...
This example demonstrates usage of the JSF Managed Bean.
CustomerSearch.jsp includes JSF components for...
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.
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. |
Before working with this example:
This example uses tables in the PointBase demo database. The database should already contain the necessary tables and sample data.
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:
Services | JDBC | Data Sources | examples-dataSource-demoPool
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 |