JSF using Eclipse


This tutorial will show you how to start a new JSF project using Eclipse with the MyEclipse plugin.

1. Your J2EE environment should be setup as described in the Setup Tutorial. Start up Eclipse, noting the amfumpuvcmil_current_url of the default workspace.

2. In Eclipse, select File -> New Project and then select "Web Project" as shown. Click Next.

3. Give your project a name of firstjsf and select options as shown. And click Finish.

4. Answer the default yes to the following if it shows up.

5. There should now be a directory structure as shown in your default workspace. The contents of WebRoot are the files that will go up to the web server. The src is where your source code of your class files are. The WEB-INF directory is secured and can not be accessed through the browser. So it is okay to put password files within it. Within WEB-INF is the deployment descriptor web.xml configuration file. Also in WEB-INF are the classes folder where you would put non-jarred files. The lib folder contains the jarred files -- two of which are jstl.jar and standard.jar.

6. Take a look at the web.xml file by right-clicking the file in Package Explorer and choose Open With -> Text Editor.

7. Now we need to add the the JSF capabilities to our project by right-clicking on the project node and selecting as shown.

8. Make the selection as shown and click finish.

9. Note that Eclipse has added the following to the web.xml.

This means the url with pattern *.faces will be processed by the Faces Servlet whose actual full classname is javax.faces.webapp.FacesServlet. Note that although the url pattern ends in *.faces, the actual files will still have the extension *.jsp.

10. In addition a JSF configuration file called faces-config.xml has been added to WEB-INF.

11. Create a first index.jsp file by ...

12. Click the deploy icon on the toolbar. In the Manage Deployment dialog, click Add. Configure your Tomcat deployment as sh

Click Finish and you should get ...

Note that you the application is deployed to the Tomcat webapp directory...

13. Start the Tomcat5 application server by ...

You know that Tomcat has started when you see...

14. Select the "Run" icon in the tool bar and setup a new configuration as shown.

Click Run to run your application in the browser.

Alternatively, you can test your application by typing in the URL in the browser.

15. Stop the Application Server in a similar manner as how you started it.

0 comments: