How not to set an attribute of a component inside a composite component if it is empty?

后端 未结 1 1865
悲哀的现实
悲哀的现实 2021-01-15 13:17

I have a h:graphicImage in a composite component like this:


    

        
相关标签:
1条回答
  • 2021-01-15 14:00

    You can conditionally add attributes via <c:if><f:attribute>.

    <h:graphicImage ...>
        <c:if test="#{not empty cc.attrs.height}"><f:attribute name="height" value="#{cc.attrs.height}" /></c:if>
        <c:if test="#{not empty cc.attrs.width}"><f:attribute name="width" value="#{cc.attrs.width}" /></c:if>
    </h:graphicImage>
    

    See also:

    • JSTL in JSF2 Facelets... makes sense?
    0 讨论(0)
提交回复
热议问题