To support the JavaServer Faces framework (JSF), IntelliJ IDEA provides:
- The Java EE: Java Server Faces plugin. This plugin is bundled with the IDE and enabled by default. However, it's always worth making sure that this plugin is still enabled before you start developing a JSF application.
A dedicated facet type (JSF).
A JSF facet provides facilities for developing JSF applications, and
lets you set up an appropriate module structure as well as
corresponding deployment descriptors and configuration files.
It also lets you download JSF implementation libraries (e.g. Apache
and JSF component libraries such as RichFaces,
A JSF facet is an extension to a Web facet, therefore a Web facet should be created first.
On this page:
- Making sure that the Java Server Faces plugin is enabled
- Creating a module with a JSF facet
- Adding a JSF facet to an existing module
- Open the Settings dialog (e.g. Ctrl+Alt+SCtrl+Alt+SCtrl+Alt+SCtrl+Alt+SCtrl+Alt+SCtrl+Alt+SAlt+F7Ctrl+Alt+SCtrl+Alt+SCommand CommaCommand CommaCommand Comma).
- In the left-hand part of the dialog, under IDE Settings, select Plugins.
- In the right-hand part of the dialog, on the Plugins page, type faces in the search box. As a result, only the plugins whose names and descriptions contain faces are shown in the list of plugins.
- If the check box to the left of Java EE: Java Server Faces is not selected, select it.
- Click OK in the Settings dialog.
- If suggested, restart IntelliJ IDEA.
Depending on the situation, you can choose to create a new project with a Java module or to add a Java module to an existing project.
Do one of the following:
If you are going to create a new project:
click Create New Project on the Welcome
select File | New Project.
As a result, the New Project wizard opens.
If you are going to add a module to an existing project:
open the project you want to add a module to,
select File | New Module.
As a result, the New Module wizard opens.
- If you are going to create a new project: click Create New Project on the Welcome screen or select File | New Project.
- On the first page of the wizard, in the left-hand pane, select Java Module.
- In the right-hand part of the page, specify the associated settings and click Next. (See the descriptions of the settings for a new project or for an existing project.)
- On the next page of the wizard (the Technologies page), select the Web Application check box. Select the version of the Servlet specification to be supported from the Versions list. If you want the deployment descriptor web.xml file to be created, select the Create web.xml check box.
- Select the JSF check box. If you want the configuration file faces-config.xml to be created, select the Create faces-config.xml check box.
Select the required library option and, if necessary, specify the associated settings. You can choose to:
Download and use a JSF implementation library.
To do that, under Libraries, select Download.
Now, to view or modify the associated options, click Configure, and in the Downloading Options dialog that opens:
- Select the JSF version that the library should implement.
- Specify the library name.
- Select the library level (global, project, or module).
- Under Files to download, select which of the files you want to download.
- Under Copy downloaded files to, specify the path to the destination folder. If you want to change the default path, click and specify the folder location in the dialog that opens.
Use a JSF library IntelliJ IDEA is already aware of.
To do that, click Use library and select the required library from the list.
If necessary, configure the library settings (for example, change its name). This is done in the Edit Library dialog which you can open by clicking Configure.
The contents of the Use library list may be different depending on the situation:
- If your are creating a new project, this list contains the JSF libraries already defined in IntelliJ IDEA as global libraries.
- If your are adding a new module to an existing project, this list, in addition, contains the project-level libraries of the current project.
Create a new library using the appropriate JAR files available on your computer.
To do that, click Use library and then click Create. Select the required JAR files in the dialog that opens. (Keep the Ctrl key pressed to perform multiple selection.)
If necessary, configure the new library (for example, change its name or level). To do that, click Configure and specify the required settings in the Create Library dialog.
- Postpone setting up the library until a later time. In this case, select Set up library later.
- Download and use a JSF implementation library.
- If you are going to use a JSF component library or libraries (e.g. PrimeFaces, RichFaces, etc.), select the corresponding check box or check boxes under JSF and specify the associated options. The procedure is similar to that for the JSF implementation library.
- If, at this step, you are ready to specify the Web server you are going to deploy your application to, do so. This will result in the corresponding server-specific run/debug configuration for your module generated automatically. Otherwise, to be able to run your application, you will have to create the run/debug configuration yourself.
- Click Finish.
As a result, IntelliJ IDEA does the following:
- Creates the module structure with the web and WEB-INF nodes (directories).
- In the web directory, creates the index.xhtml file that you can use as the starting page of your application.
In the WEB-INF directory, creates:
- web.xml, the Web application deployment descriptor.
- faces-config.xml, the JSF configuration file.
- If specified, creates a JSF library or libraries at the corresponding level and adds the library or libraries to the module dependencies.
- Creates an artifact specification for you module.
- If you have specified the server, IntelliJ IDEA also creates a run/debug configuration.
- Open the module settings.
- With the desired module selected, click on the toolbar, and, under Framework, select Web.
- If necessary, configure the Web facet resources and settings.
- Select the Web facet you have just created, click and select JSF.
- Now, to download a JSF implementation library and add it to module dependencies, in the lower part of the Facet 'JSF' page that opens in the right-hand part of the Project Structure dialog, click Fix next to the message reading JSF library not found in the module dependencies list.
- In the dialog that opens, specify the library options as necessary and click OK.
- If necessary, use the JSF Facet page to change the Facelet support option.
- To add a JSF component library (e.g. PrimeFaces), click again, and, under Framework, select the library of interest (e.g. Primefaces).
- In the dialog that opens, specify the necessary library options and click OK.
- Adding Modules to a Project
- Creating a Project from Scratch
- Configuring Project and Global Libraries
- Enabling Web Application Support