IntelliJ IDEA 2021.3 Help

Jakarta Server Faces (JSF)

Jakarta Server Faces (JSF), formerly known as JavaServer Faces, is a Java specification and MVC framework for building user interfaces for web applications.

IntelliJ IDEA provides the following:

Create a new Java Enterprise project with JSF

  1. Click New Project on the Welcome screen or select File | New | Project.

  2. In the wizard that opens, select Java Enterprise on the left.

  3. Name the new project, select a build tool, a test framework, a language you want to use, and select the Web application project template.

  4. Select the JDK that you want to use in your project.

    If the JDK is installed on your computer, but not defined in the IDE, select Add JDK and specify the path to the JDK home directory.

    If you don't have the necessary JDK on your computer, select Download JDK.

    Creating new project with JSF support
  5. On the next step of the wizard, select the Java EE version to be supported.

  6. From the Dependencies list, select the Server Faces (JSF) checkbox.

    Creating new project with JSF support
  7. Click Finish.

For more information on how to create a Java Enterprise project, refer to Tutorial: Your first Java EE application.

IntelliJ IDEA creates the default project structure with the javax.faces or jakarta.faces library as an external dependency. If you specified an application server, IntelliJ IDEA will also create a run configuration to start the server, build and deploy the artifact.

Enable JSF support for an existing project

If you already have a Java Enterprise web application, you can add the JSF framework support.

  1. Open the build file in the editor (pom.xml or build.gradle depending on the build tool that you use in your project).

  2. Add the following dependency, but make sure to change the version according to your project's requirements:

    Java EE:

    <dependency> <groupId>javax.faces</groupId> <artifactId>jsf-api</artifactId> <version>2.1</version> <scope>provided</scope> </dependency>

    Jakarta EE:

    <dependency> <groupId>jakarta.faces</groupId> <artifactId>jakarta.faces-api</artifactId> <version>3.0.1</version> <scope>provided</scope> </dependency>

    Java EE:


    Jakarta EE:

  3. Press Ctrl+Shift+O to import the changes.

For more information on how to work with build tools, refer to Maven or Gradle.

The JSF configuration file faces-config.xml defines the navigation rules between the pages of your web application. IntelliJ IDEA provides a diagram that you can use to see and draw the navigation rules instead of editing the configuration file.

  1. Open faces-config.xml in the editor and click the Navigation tab at the bottom.

  2. Drag the required pages (one at a time) from the Project tool window to the Navigation tab.

  3. Click and drag to draw the navigation lines from one page to another. IntelliJ IDEA will create the corresponding navigation rules in faces-config.xml. Switch to the Text tab to see those rules.

Using the navigation diagram to create the navigation rules
Last modified: 01 August 2022