My issue is quite simple : I want to create a composite component with a String attribute, Type.
<cc:attribute name="type" />
This attribute will have 3 acceptable values, [TYPE1, TYPE2, TYPE3]
Is it possible to say my component will accept only these values ?
Unfortunately no, you cannot put a compile/buildtime restriction on a composite component attribute value in the cc interface. You can however put a runtime restriction by checking the value in the cc implementation.
<ui:param name="type" value="#{cc.attrs.type}" />
<ui:fragment rendered="#{type == 'TYPE1' or type == 'TYPE2' or type == 'TYPE3'}">
<p>The type is TYPE1, TYPE2 or TYPE3.</p>
<p>Write your component's body here.</p>
</ui:fragment>
That'll be your best bet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With