Today you’re going to learn how to setup a PrimeFaces Theme.
More specifically we’ll configure the free Bootstrap community theme.
(FAST)
Let’s jump right in…
If you want to learn more about PrimeFaces for JSF – head on over to the JSF PrimeFaces tutorials page.
1. What are PrimeFaces Themes?
PrimeFaces is integrated with the ThemeRoller CSS Framework in order to support different themes. There are three types of themes you can configure:
- You can purchase premium themes.
- You can choose from the free community themes (click the Community tab).
- You can create your own theme using the online theme generator tool of ThemeRoller.
The following example shows how to set up the Bootstrap PrimeFaces theme using Spring Boot and Maven.
2. General Project Overview
We will use the following tools/frameworks:
- PrimeFaces 6.2
- JoinFaces 3.3
- Spring Boot 2.1
- Maven 3.5
Our project has the following directory structure:
3. Maven Setup
We start from a previous JSF Spring Boot Example in which we created a greeting dialog based on a first and last name input field.
As the PrimeFaces community themes are not available in the Maven central repository we need to specify the PrimeFaces Maven Repository in our Maven POM file as shown below.
Once this is done we need to include the dependency to the specific PrimeFaces theme we want to use.
Alternatively, we can include all available themes by specifying the all-themes
dependency. We will do the later in this example.
4. PrimeFaces Bootstrap Theme Setup
As we are using JoinFaces to setup Spring Boot we can use an application property in order to configure a PrimeFaces theme.
We set the Bootstrap theme by specifying the jsf:primefaces:theme property in src/main/resources/application.yml as shown below.
Let’s check the new look of our web application. Execute following Maven command:
Once Spring Boot has started, open a web browser and enter the following URL: http://localhost:8080/helloworld.xhtml.
The web page should now be displayed in the newly configured theme.
If you would like to run the above code sample you can get the full source code here.
In this post, we illustrated how to configure the PrimeFaces Bootstrap theme using Spring Boot and Maven.
Drop a line below if you enjoyed reading this post.
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/271568.html