...
Step 1: Take a look at the examples
Your first step with Apache MyFaces should be to have a look at our examples application. In the following links (kindly hosted by Irian Solutions GmbH) you will find demo applications running with MyFaces.
...
The most simple example you can try is the ones bundled with tomahawk, which at the begining of MyFaces project was the example application bundled with MyFaces Core.
What you need for the Examples Application
- A web server like Apache Tomcat. The example shown runs on 5.x, 6.x or 7.x, but note JSF 1.2 and later versions requires tomcat 6.x or upper. Download it from here.
- Go to Tomahawk download page and download the webapps assembly (tomahawk-examples-X.X.X.zip or tomahawk-examples-X.X.X.tgz)
Installing and Running the Examples
- Unpack the MyFaces examples archive tomahawk-examples.X.X.X.zip (or tomahawk-examples-X.X.X.tgz) to a directory of your choice.
- Remove any previous MyFaces webapps from your Tomcat installation and clean up your Tomcat work dir. Also make sure that there is no jsf-api.jar or jsf-impl.jar (i.e. Suns API and implementation) in the classpath or in one of Tomcat's lib directories (for Tomcat 5.x look on common/lib or shared/lib, in tomcat 6.x or 7.x look on /lib folder).
- Copy the file myfaces-example-simple.war (or any of the other example war-files, myfaces-example-simple20.war for JSF 2.0 variant) to the webapps dir of your Tomcat installation directory - and check once more that there is no old myfaces-examples .tgz)directory there
- Start Tomcat, if its not already running.
- Start your browser and enjoy it at http://localhost:8080/myfaces-example-simple20.
Using MyFaces in your own web application
Suggested step:
- Check the myfaces wiki for information about compatibility with your servlet container.
There are three possible ways to start off with MyFaces, one (recomended) is to start using myfaces archetypes:
- Download and Install Maven
- Execute mvn archetype:create goal using one available archetype. For more info you can look here
The second possibility is to start from the example-app:
- If you want to have it simple, take the tomahawk-examples-X.X.X.zip you downloaded before for looking at the examples, and extract the myfaces-examples-blank-X.X.X.war file (MyFaces binary)
- Rename the myfaces-examples-blank-X.X.X.war file to myfaces-examples-blank-X.X.X.zip, and extract this file - you have a working directory structure for a MyFaces application at hand after this step.
The third possibility is to download the core implementation and/or tomahawk (dependent on if you want to use the RI and the tomahawk components, or only MyFaces), and start from there:
- Alternatively, download the latest MyFaces binary release. You can download only the implementation (aka core) or the implementation and tomahawk.
- Copy all *.jar files into your WEB-INF/lib directory. Some of the jar-files are optional, you can find more info on: http://myfaces.apache.org/impl/dependencies.html and http://myfaces.apache.org/tomahawk/dependencies.html
After you have downloaded the necessary packages and setup your project hierarchy, do this:
*Make sure that there is no jsf-api.jar (i.e. Suns API implementation) in the classpath or in one of your container's shared lib directories (e.g. common/lib or shared/lib for Tomcat).
- Configure your webapp's web.xml file (see conf/web.xml for example and documentation)
- Add the following lines to your JSPs:
...
Using the MyFaces Tomahawk in your own web application
- If you don't use the MyFaces implementation, you will need to add the file tomahawk.jar and its dependencies (see above) to your web-app directory.
- To be able to use the MyFaces Tomahawk add the following line to your JSPs:
...
- For using the Tomahawk components, it's also very important to setup the MyFaces Extensions-Filter. You find the explanations for doing this under: http://myfaces.apache.org/tomahawk/extensionsFilter.html
Tutorials for getting started with JSF
...