Shahe
Shahe

Reputation: 984

Conditionally exclude a CSS resource file in template depending on template client

In my project, I have a main template page main_template.xhtml that has all the resource file includes.

I have a styles.css in the main template that contains styling classes of my pages. In one particular page I want to exclude the styles.css resource file, how can I achieve that?

Upvotes: 1

Views: 209

Answers (1)

BalusC
BalusC

Reputation: 1109302

As every other UI component, the <h:outputStylesheet> also supports the rendered attribute. You can grab the current view ID by UIViewRoot#getViewId() and just check on that.

So, pieces put together that would look like:

<h:outputStylesheet ... rendered="#{view.viewId ne '/specific.xhtml'}" />

See also:

Upvotes: 1

Related Questions