开发者

include optional css file in xhtml?

开发者 https://www.devze.com 2023-03-27 04:52 出处:网络
I have an xhtml page where I do include some css files like: &开发者_如何学Pythonlt;link href=\"resources/css/graCommon.css\"

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

&开发者_如何学Pythonlt;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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号