I'm encountering problem with a custom tag.
Here's the problem. I created a tag which is used in my JSF pages :
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:t="http://myfaces.apache.org/tomahawk"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jstl/core">
... some stuff ...
<h:inputText id="#{id}" value="#{value}" binding="#{binding}" label="#{label}"/>
... some stuff ...
</ui:composition>
I want to use this component in my pages in this way (my component is named gp:inputText) :
<gp:inputText value="#{myBean.myValue}" id="myId" label="myLabel" binding="#{myBean.myUiComponent}" />
But I also want to use the same component but without binding the inputText. How can I do that? I tried to just use my component without specifying the binding but it doaes not work. It seems that the binding value cannot be null like the label value for example.
Thanks for the help !
It's not possible to define a binding attribute without a correct value.
However, you can avoid to define a binding attribute when it's null, like this :
<h:inputText id="#{id}" value="#{value}" label="#{label}">
<c:if test="#{binding != null}" >
<f:attribute name="binding" value="#{binding}" />
</c:if>
</h:inputText>