JBoss.orgCommunity Documentation

Chapter 2. Creating a CDI Web Project

From the workbench go to FileNewOther.

Wizard selection screen with the CDI Web Project wizard selected.

Figure 2.1. Selecting the CDI Web Project wizard


The first screen of the wizard will ask you to define the attributes according to the options outlined in Table 2.1, “New CDI Web Project”. Click the Next button after defining the attributes in order to continue customizing your project or click the Finish button to accept all other defaults and create your application.

The main options to define and select for your project.

Figure 2.2. Main project creation screen


Table 2.1. New CDI Web Project

FieldMandatoryInstructionDescription
Project nameyesEnter a project name.The project name can be any name you define.
Project locationyesThe Use default location checkbox will be selected automatically to define the project location as the Eclipse workspace. However you can define a custom path in the Location field be deselecting the Use default location checkbox.The default location corresponds to the Eclipse workspace.
Target runtimenoSelect a pre-configured runtime from the available options or configure a new runtime environment.

The target runtime defines the server to which the application will be deployed.

Dynamic web module versionyesSelect the required web module version.

This option adds support for the Java Servlet API with module versions corresponding to JEE or J2EE levels as listed in Table 2.2, “New CDI Web Project - Dynamic web module version”.

ConfigurationyesSelect the project configuration from the available options.

The project can be based on either a custom or a set of pre-defined configurations as described in Table 2.3, “New CDI Web Project - Configuration”.

EAR membershipnoAdd the project to an existing EAR project.

The project can be added to an existing EAR project by selecting the checkbox. Once checked, a new EAR project can be defined by clicking the New Project button.

Working setsnoAdd the project to an existing working set.

A working set provides the ability to group projects or project attributes in a customized way to improve access. A new working set can be defined once the Select button has been clicked.


Table 2.2. New CDI Web Project - Dynamic web module version

OptionDescription
3.0This web module version corresponds to the JEE 6 implementation.
2.5This web module version corresponds to the JEE 5 implementation.
2.4This web module version corresponds to the J2EE 1.4 implementation.
2.3This web module version corresponds to the J2EE 1.3 implementation.
2.2This web module version corresponds to the J2EE 1.2 implementation.

Table 2.3. New CDI Web Project - Configuration

OptionDescription
Dynamic Web Project with CDIThe default configuration option. Choosing this configuration will create a Dynamic Web Project with the CDI facet enabled.
Default configuration for the runtime specified in Target runtimeDepending on the runtime configuration, you may have to manually add CDI facet support through the Modify button.
JavaServer Faces v2.0 ProjectConfigures a project to use JSF v2.0. You will need to manually add CDI support to this configuration through the Modify button.
Minimal ConfigurationThe minimum required facets are installed. You will need to manually add CDI support to this configuration through the Modify button.
<custom>Total manual configuration is required through the Modify button. Ensure you enable the CDI facet for CDI Web Project creation to succeed.

The Java configuration screen allows you to define Source folders on the build path and the Default output folder. The defaults for each are recommended, however you have the option to change them as you see fit.

Java configuration screen for your project.

Figure 2.3. Java configuration screen


The Web Module configuration screen allows you to define the Context root and the Content directory to be created, the option to Generate web.xml deployment descriptor is selected by default. The defaults for each are recommended, however you have the option to change them as you see fit.

Web Module configuration screen for your project.

Figure 2.4. Web Module configuration screen


The Context and Dependency Injection (CDI) Facet settings configuration screen allows you to Generate beans.xml file, selected by default. The beans.xml file is a bean archive descriptor that allows you to enable CDI services for a bean archive. It is recommended that you leave the option selected.

Web Module configuration screen for your project.

Figure 2.5. Web Module configuration screen


The final screen of the wizard pertains to JSF Capabilities configuration.

JSF Capabilities configuration screen for your project.

Figure 2.6. Web Module configuration screen


Table 2.4. JSF Capabilities

FieldMandatoryInstructionDescription
JSF Implementation Library TypeyesSelect an implementation library from the list provided.This option adds support for the JSF implementation library, required for the project to function correctly. For a description of available options see: Table 2.5, “JSF Capabilities - JSF Implementation Library”.
Configure JSF servlet in deployment descriptornoSelected by default, decide whether to configure the deployment descriptor for the JSF servlet or not.This option, if selected, opens up the ability to configure various deployment descriptor fields. For a description of fields see: Table 2.6, “JSF Capabilities - JSF Servlet Configuration”.

Table 2.5. JSF Capabilities - JSF Implementation Library

OptionDescription
Library Provided by Target RuntimeIf you selected a target runtime on the first screen, this option will configure the project to use the required facet library that is provided by the target runtime.
User LibrarySelecting the User Library option allows you to specify one or more custom user libraries to be used. At least one must be selected for the wizard to complete successfully.
Disable Library ConfigurationIf you choose to disable library configuration you will have to configure the project classpath at a later time, by alternate means, before running the project.

Table 2.6. JSF Capabilities - JSF Servlet Configuration

FieldMandatoryInstructionDescription
JSF Configuration FileYesEnter the location of the JSF configuration file (the default is usually correct).You must specify where the JSF configuration file is located.
JSF Servlet NameYesSpecify a name for your JSF servletThe name of the servlet.
JSF Servlet Class NameNoSpecify a name for your servlet class.Naming your servlet class will allow for easy reference to it when you are coding for your project in the future.
URL Mapping PattersNoA default mapping pattern is provided. You are able to remove and add patterns as you wish.This option allows for the creation of constant, readable URLs, based on patterns, that map to your project.

Click the Finish button to create your CDI Web Project.