5

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 ?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
boblemar
  • 1,143
  • 1
  • 10
  • 24

1 Answers1

6

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.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thank you, it's not a big problem for me... But I think it would have been quite clean. Nevermind ! – boblemar Oct 26 '11 at 13:24