Reputation: 3336
I have a composite component (CC) that renders a inputText. I have a attribute called "autoFocus" in CC that should be rendered in inputText only when it values is true, see the code:
<composite:attribute name="myAutoFocus" default="false" type="java.lang.Boolean"/>
So, inside composite:implementation i have the following:
<h:inputText pt:autofocus="#{cc.attrs.myAutoFocus}" />
In this way my autoFocus is always enable, because "autofocus=false" and "autofocus=true" is both TRUE. So i need a way to render the autoFocus looking for my CC attribute value.
Upvotes: 0
Views: 571
Reputation: 3336
I used c:if
to conditionally render the autofocus attribute via the f:passThroughAttribute
from JSF 2.2 to solve my problem:
<h:inputText>
<c:if test="#{cc.attrs.myAutoFocus}">
<f:passThroughAttribute name="autofocus" value="autofocus"/>
</c:if>
</h:inputText>
Upvotes: 2