In my JSF 2.1 project i defined a custom tag file which includes a h:inputText
element. This element may or may not include a binding
attribute – depending on the passed parameters of the custom element.
Example formInput.xhtml (excerpt):
<h:inputText id="#{id}" value="#{value}">
<c:if test="#{not empty binding}">
<f:attribute name="binding" value="#{binding}"/>
</c:if>
</h:inputText>
Usage from other file:
<e:formInput id="test" value="#{testBean.myValue}" binding="#{testBean.myBinding}"/>
Unfortunately this doesn't work. #{not empty binding}
resolves to false and the binding is not applied.
However, defining the binding
attribute without a condition does work.
Example:
<h:inputText id="#{id}" value="#{value}">
<f:attribute name="binding" value="#{binding}"/>
</h:inputText>
In this case the binding is applied correctly.
Does anyone know how to set the binding conditionally?