How to ignore empty attributes within a composite component?
How can i ignore empty attributes of a composite component? Example:
<cc:interface>
<cc:attribute name="styleClass" />
<cc:attribute name="value" />
</cc:interface>
<cc:implementation>
<h:inputText styleClass="#{cc.attrs.styleClass}"
value="#{cc.attrs.value}">
<cc:insertChildren />
</h:inputText>
</cc开发者_C百科:implementation>
When i use the component by this:
<my:inputText />
It is rendered like this:
<input type="text" class="" />
How can i get an output without the empty class-attribute?
You can use it like this:
<my:inputText styleClass="myClass"/>
or you can set the default in your compoent:
<cc:attribute name="styleClass" default="myClass"/>
If you don't set the styleClass, then it is set to the default.
精彩评论