0

Simple question I hope..I have my java class where a value is set to 3:

private static final Integer MAX_LANGUAGES = 3;

Could you give me an example how to make a composite attribute that will specify the maximum number of languages a user can select. It is now stored in the class but I would like it to be more flexible, because the class shouldnt depend on that number.

Marko Ćilimković
  • 734
  • 1
  • 8
  • 22

1 Answers1

1

Are your talking about composite components?

If so, you can use the composite:attribute tag to add an attribute to your component.

E.g:

<composite:interface>
    <composite:attribute name="maxLanguages"/>
</composite:interface>

<composite:implementation>
    <h:outputFormat value="Maximum languages = {0}">
           <f:param value="#{cc.attrs.maxLanguages}"/>
    </h:outputFormat>
</composite:implementation>

You can also attach a real java model to it with the componentType attribute of composite:interface and access it properties with cc.propertyName

Sebastian Hoffmann
  • 11,127
  • 7
  • 49
  • 77