Using MyFaces with Oracle JDeveloper 10g (10.1.3) Preview
Using MyFaces with Oracle JDeveloper 10g (10.1.3) Preview
Written by Jonas Jacobi, Oracle Corporation
February, 2005
Revision 1.0
Using MyFaces implementation and components
This HowTo explains how to use the MyFaces implementation and the MyFaces custom components with Oracle JDeveloper 10g (10.1.3) Preview
and ADF Faces. This HowTo
is divided into two parts - one that is explaining how to get MyFaces custom
components installed within Oracle JDeveloper 10g (10.1.3), and the second part is covering how to get
Oracle ADF Faces components up and running with the MyFaces implementation. For more information and HowTos, please, refer to the
JDeveloper
page on Oracle
Technology Network (OTN).
MyFaces is an open source project that can be found under the umbrella of the
Apache foundation. MyFaces is an alternative JavaServer Faces (JSF)
implementation to the JSF Reference Implementation (RI) provided by Sun.
In most cases developers will be satisfied using what ever JSF implementation is
provided with the tools. Oracle JDeveloper 10.1.3 Developer Preview has built-in
support for the Sun Reference Implementation. In the JDeveloper 10.1.3 Developer Preview
developers are restricted in that they cannot switch out the provided JSF
implementation with another implementation such as MyFaces. In the production
release of JDeveloper 10.1.3 developers will be able to switch out the by
default provided RI and use a JSF implementations of their choice.
Here
follows the steps to setup Oracle JDeveloper 10.1.3 Developer Preview to use the
MyFaces extension library contain a set of custom JSF components with the Sun RI:
Then download the MyFaces binary files from the
MyFaces site or directly from the MyFaces
build system.
Note: If you decide to take a build from the build you should download the file -
myfaces-1.0.8.tgz. In this example we are using the file located on the
build system.
Extract the file and locate a file that is called "myfaces-extension.jar" for the
1.0.8 version of MyFaces. This file is located in the [extract_location]\myfaces-1.0.8\lib.
Start JDeveloper 10.1.3 Developer Preview.
Click on the Tools menu and select the Manage Libraries...
option.
Select the JSP Tag Libraries tab.
Click on the Users node in the left pane, and then on the New
button at the bottom of the list.
Locate and select the myfaces-extension jar file described in step 3. Click
Open.
You should now have a node that in the left pane says "x 0.9.0" and the
right side should be populated with information about the MyFaces extension
TLD.
Change the display name from "x" to "MyFaces Extension".
Before you close the dialog make sure you check the "Execute Tags in JSP
Visual Editor" option to enable live rendering of these custom components.
You are now done with installing MyFaces components in to JDeveloper. If you
need to add these components to an already existing project you will have to add
the tag library to your Project properties. If you create an application or page
from scratch you have the option to add them in the New Page wizard.
Due to the aforementioned restriction in the Oracle JDeveloper 10.1.3 Developer
Preview developers have to first create their ADF Faces application with the RI
as a base. When the application is done and ready for deployment the developer
can swap out the RI libraries and replace them with the
MyFaces libraries. To illustrate how to setup an application built with ADF Faces components with
the MyFaces implementation we will use the ADF Faces demo bundle.
Here is how you do it:
Download the ADF Faces complete standalone install (adf-faces-ea13.zip)
from
OTN.
Extract the file and locate the adf-faces-demo.zip file. Should be
located at the root of the adf-faces-ea12 directory. Note: The file adf-faces-demo.zip is a demo WAR with missing third party
libraries. It has been renamed to a ZIP so that users don't try to run it
without the missing libraries.
Extract adf-faces-demo.zip. We'll call the directory you unzip it into
[DEMO_HOME].
In the [DEMO_HOME]/WEB-INF/lib directory remove the following libraries:
jstl.jar
commons-logging-1.0.3.jar
commons-digester-1.5.jar
commons-collections-2.1.jar
commons-beanutils-1.6.jar
Get the missing MyFaces JSF 1.0.8 JAR files - download the tgz file
'myfaces-1.0.8.tgz'. Extract the following jars to [DEMO_HOME ] /WEB-INF/lib
(WinZip's "Use Folder Names" option should be unchecked):
All 'commons-*.jar'
All 'myfaces-*.jar'
jakarta-oro.jar
jstl.jar
jsp-2.0.jar
Before we are ready to deploy there are some changes needed in the WEB.XML
file. The web.xml is located in the [DEMO_HOME ] /WEB-INF directory. We need to
include the StartupServletContextListener class.
Note: This class is needed to be able to parse the faces-config.xml file and
should be implemented into to the myfaces-core.tld instead of having it defined
in the web.xml file.
Add the following code snippet just below the <web-app> tag at the top
of your web.xml file:
Select File -> New -> General -> Workspaces -> Application
workspace.
In the new workspace, create a project from a WAR file.
Select File -> New -> General -> Projects -> Project from WAR File.
In step 1 of the wizard, name the project "demo" and
accept the default directory location.
In step 2, locate the WAR file (adf-faces-myfaces-demo.war).
Click Finish. This will expand the WAR file contents
into your new project directory. You should now see your new project in the
Application Navigator.
Take a few seconds to familiarize yourself with the
various files in this application. You'll find the adf-faces-config.xml
along with other files in the WEB-INF directory.
Make sure you enable "J2SE 1.4 Assertions" in the
project properties under the Compiler category.