Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enum values in Composite Component attribute

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 ?

like image 394
boblemar Avatar asked Oct 26 '11 12:10

boblemar


1 Answers

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.

like image 196
BalusC Avatar answered Oct 15 '22 19:10

BalusC