- Open the Settings dialog (e.g. Ctrl+Alt+SCommand 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 js in the search box. As a result, only the plugins whose names and descriptions contain js are shown in the list of plugins.
- If the check box to the left of JSF Support 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 screen or
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, and
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 Version list.
- Select the JSF check box, and select the JSF version to be supported from the Version list.
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 CtrlControl 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. If this is your intention, 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.jsp 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.
Taking into account the initial module structure and contents, you will be able to access the index.jsp page (after deployment of the corresponding module artifact to a Web server) using the following URL: http://<host>:<port>/<context_root>/index.faces.
- 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.