NKS
NKS

Reputation: 1160

Multiple Primefaces themes in single JSF application

We need to use multiple primefaces JSF themes in a single web application, we have several modules in the application each having their own few screens, and we want each module to have different primefaces theme,

can anyone please let us know how that can be achieved.

in web.xml we have specified :

<context-param>
    <param-name>primefaces.THEME</param-name>
    <param-value>start</param-value>
  </context-param>

thanks

Upvotes: 3

Views: 2028

Answers (2)

Ali Saleh
Ali Saleh

Reputation: 258

Setting the primefaces theme in the Web.xml file will effect the whole application, but there is a workaround for this as the following:

  1. Download the needed primefaces themes as jar files (ex: sunny)
  2. In the web resources folder, create a sub-folder "primefaces-sunny"
  3. extract the theme jar and copy the "theme.css" and "images" folder to the created sub-folder "primefaces-sunny"
  4. now create a template (facelet template) for each module
  5. in each template include the target stylesheet < h:outputStylesheet library="primefaces-sunny" name="theme.css" />
  6. let each page in the module use the module template page

thats it :)

Upvotes: 1

Ramazan Yildiz
Ramazan Yildiz

Reputation: 71

Per page you can get it. in web.xml, you can write:

<context-param>
   <param-name>primefaces.THEME</param-name>
   <param-value>#{sessionBean.userTheme}</param-value>
</context-param>

and set userTheme in backing bean each time page changed.

Otherwise, you may extend primefaces components. Then specify specific themes per component.

Upvotes: 5

Related Questions