Hi,
Actually, I am not familiar with the usage of PrimeFaces and Spring Boot, but when I searched for a solution suggestion, you can try the following result:
1-Create a GuestPreferences bean to hold the theme preference for each user. Make sure it has a theme property that can be updated dynamically.
2-In your application.properties or application.yml file, configure the primefaces.THEME parameter to be dynamically linked with the guestPreferences.theme value.
-For application.properties, add the following line:
Code: Select all
primefaces.THEME=${guestPreferences.theme}
-For application.yml, add the following configuration:
Code: Select all
primefaces:
THEME: ${guestPreferences.theme}
By using ${guestPreferences.theme}, the primefaces.THEME parameter will be associated with the value of guestPreferences.theme and updated accordingly.
3-Ensure that your GuestPreferences bean is properly managed by Spring and available for injection.
4-When your Spring Boot application starts or refreshes, Spring Boot will read the primefaces.THEME parameter from the configuration file and link it with the guestPreferences.theme property.
This allows you to update the theme property of the GuestPreferences bean dynamically, and PrimeFaces will automatically use the updated theme value.
To summarize, the correct approach is to configure the primefaces.THEME parameter in your application.properties or application.yml file and link it with the guestPreferences.theme value. This leverages Spring Boot's configuration mechanism to update the PrimeFaces theme dynamically.
I hope it helps.
Best Regards