jsfxhtmlicefacesjsf-1.2icefaces-1.8

include optional css file in xhtml?


I have an xhtml page where I do include some css files like:

<link
    href="resources/css/graCommon.css"
    rel="stylesheet"
    type="text/css" />
<link
    href="resources/css/txMart.css"
    rel="stylesheet"
    type="text/css"/>

I do need to include the second CSS file based on some conditions (for instance, using a bean property etc). So I need some sort of jsf/icefaces tag having an attribute like render or visible...

Are you aware of something like that?

Thanks


Solution

  • The following should work for build time

    <c:if test="#{yourExpression}">
        <link
        href="resources/css/txMart.css"
        rel="stylesheet"
        type="text/css"/>
    </c:if>
    

    Will include your tag in the facelet depending on your expression, you will need to include the "c" namespace

    or

    <ui:fragment rendered="#{yourExpression}">
        <link
        href="resources/css/txMart.css"
        rel="stylesheet"
        type="text/css"/>
    </ui:fragment>
    

    See https://rogerkeays.com/jsf-c-foreach-vs-ui-repeat for the differences in each approach