JBoss.orgCommunity Documentation

Chapter 3. Projects

3.1. Creating a New JSF Project
3.2. Importing Existing JSF Projects with Any Structure
3.3. Adding JSF Capability to Any Existing Project
3.4. Adding Your Own Project Templates
3.5. Relevant Resources Links

To take an advantage of JSF you will need to perform one of the next steps:

This section will go into more detail for each step.

It is easy to create a new project that contains all the JSF libraries, tag libraries and JSF configuration file with the aid of a special wizard. To get it, select FileNewOtherJBoos Tools WebJSFJSF Project and click the Next button.


On the next page you will be prompted to enter the Project Name and select a location for the project (or just leave a default path).

The JSF Version option also allows you to specify the JSF implementation to use.


There are a number of predefined project templates that are both flexible and easily customizable. You can pick a different template on which the projects Importing Existing should be based on. Almost all templates come in two variations: with and without JSF libraries.


The table below provides description for each possible JSF template.


On the next page you need to select which Servlet version to use, and specify whether or not to register this application with JBoss AS (or other server) in order to run and test your application.

The Context Path option defines the name under which the application will be deployed.

The Runtime value tells Eclipse where to find the Web libraries necessary to build (compile) the project. It is not possible to finish the project creation without selecting a Runtime. If you do not have any values, click the New... button to add new Runtime.

The Target Server option allows you specifying whether or not to deploy the application. The Target Server corresponds to the Runtime value selected above. If you do not want to deploy the application, uncheck this option.


When you are all done, you should see that the project has appeared in the Package Explorer view:


At this point you can open the faces-config.xml file and start working on your application. There are a lot of features available when developing JSF applications. These features will be discussed in more detail later in this document.

For detailed information on migration of JSF projects into a workspace see the Migration Guide.

It is also possible to add JSF™ capabilities (JSF libraries, tag libraries) to any existing project in your workspace. After that you will be able to make use of features such as the JSF configuration editor, JBoss Tools JSP editor and any others. No pre-existing web.xml file is necessary.

Right-click on the project in the Project Explorer, bringing up the context menu. From this menu navigate to ConfigureAdd JSF Capabilities.


This will open the Project Facets dialog for the project. Click the checkbox next to JavaServer Faces. You undertake further configuration by clicking the Further configuration available button at the bottom of the dialog; this will allow you to define specific configuration options. Click Apply and then the OK on the Project Facets dialog when you are finished.


The project will now contain a new node (visible through the Project Explorer) named Web Resources.You will also notice new files within the WebContent folder.

Note:

Some application servers provide their own JSF implementation libraries. To avoid conflicts you should not add JSF libraries while adding JSF capabilities.

You can now open the new faces-config.xml file, that is found under your projects WebContentWEB-INF folder. This file can be opened in a unique editor (see Chapter 5, JSF Configuration File Editor).

A template is a set of files that is provided as a basis when creating a new project. Project templates provide content and structure for a project.

JSF Tools provides powerful template capabilities which allow you to create new templates and import existing JSF projects. This templating facility has a variety of aspects to consider. Let's start with the most straightforward case and consider the process of creating a template from your existing JSF project.

Let's say you have a project that you want to use as the basis for a new template. The following steps will show you how to achieve this:


  • In the first dialog box, you can specify a name for the template (it will default to the project name) and confirm what run-time implementation of the project technology will be used.


  • When you click the Next button a dialog box will be presented with your project structure displayed, along with a number of check boxes. Here you can select only those parts and files in your project directory that should be part of the template.


  • At this point, unless you want to designate some extra files as having Velocity template coding inside them, you should click the Finish button.

That's it. This template can be used with any new or imported project that uses the same run-time implementation as the project you turned into a template.

At this point you have a fully configured project. Now you can add some additional logic to it starting with the JSF configuration file.

You can find a more in-depth explanation on how to work with the special wizards, editors and views that can be used while developing JSF applications in our Visual Web Tools Guide.