开发者

How to ignore empty attributes within a composite component?

开发者 https://www.devze.com 2023-03-27 17:13 出处:网络
How can i ignore empty attributes of a composite component? Example: <cc:interface> <cc:attribute name=\"styleClass\" />

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消