Reputation: 199
I am wondering if there is a nice way to decorate components with composite components?
Example:
<composite:implementation>
<div style="someFancyClass">
<h:inputText value="#{cc.attrs.value}" />
</div>
</composite:implementation>
In this case the value attribute is passed through to the contained <h:inputText>
. But what about all the other attributes? Do I have to declare all of them in the <composite:interface>
section?
It would be nice to have some kind of inheritance from standard components, so that e.g. the maxlength attribute of <h:inputText>
is automatically available at the composite component.
Upvotes: 1
Views: 1274
Reputation: 2099
I provided an example on how to decorate a composite component here https://stackoverflow.com/a/8881510/1151983
However, this does not provide real inheritance, but a way to share common stuff between a set of similar composite components.
Upvotes: 0
Reputation: 1109422
Do I have to declare all of them in the
<composite:interface>
section?
Not necessary, you can just use maxlength="#{cc.attrs.maxlength}"
without the need to declare it as <composite:attribute>
. However, this is bad for documentatory purposes. The developer would not see this attribute to appear in the composite component's documentation (which might be used by IDE autocompletion, for example).
It would be nice to have some kind of inheritance from standard components, so that e.g. the maxlength attribute of
<h:inputText>
is automatically available at the composite component.
That's not possible. For that you'd really need to create a fullworthy custom UIInput
component and/or a Renderer
(in your particular case, just the renderer ought to be sufficient).
Upvotes: 1