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:
Coding assistance specific to JSF, including popular JSF component libraries:
Graphical editor for defining page navigation rules.
Create a new Java Enterprise project with JSF
Click New Project on the Welcome screen or select .
In the wizard that opens, select Java Enterprise on the left.
Name the new project, select a build tool, a test framework, a language you want to use, and select the Web application project template.
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.
On the next step of the wizard, select the Java EE version to be supported.
From the Dependencies list, select the Server Faces (JSF) checkbox.
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.
Open the build file in the editor (pom.xml or build.gradle depending on the build tool that you use in your project).
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:
compileOnly('javax.faces:javax.faces-api:2.3')Jakarta EE:
compileOnly('jakarta.faces:jakarta.faces-api:3.0.1')Press Ctrl+Shift+O to import the changes.
For more information on how to work with build tools, refer to Maven or Gradle.
Navigation diagram
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.
Open faces-config.xml in the editor and click the Navigation tab at the bottom.
Drag the required pages (one at a time) from the Project tool window to the Navigation tab.
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.