1

I was wondering if there is a way to targets all possible additional attribute to a given component, something like a wildcard. In the following example, I would like to target all attribute to the component btn. Typically, I would like to target all the JavaScript attributes (onclick, onsubmit, etc.) and I don't want to copy the whole list of attributes. Is there a way to simplify that?

<composite:interface>
    <composite:attribute name="action" targets="btn" required="false" />
    <composite:attribute name="onkeydown" targets="btn" required="false" />
    <composite:attribute name="onkeyup" targets="btn" required="false" />
    <composite:attribute name="onclick" targets="btn" required="false" />
    <!-- Here other attributes with targets="btn" -->
</composite:interface>
<composite:implementation>
    <p:commandButton id="btn" />
    <!-- additional code (not relevant for the question) -->
</composite:implementation>
LaurentG
  • 11,128
  • 9
  • 51
  • 66

1 Answers1

2

Is there a way to simplify that?

No. Just bite the bullet and copypaste them all and live with verbosity of declarative nature of XML.

Note that with your proposed approach the Facelet file editors (e.g. Eclipse) won't be able to propose the right attributes on autocomplete of <your:composite> in template client. Also, Facelet tag library documentation generators like Vdldoc won't be able to list the right attribtues in the documentation.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thank you for the answer. Is there any better approach for creating reusable "templates"? – LaurentG Sep 10 '13 at 18:06
  • Not sure what you mean with "better". You can at least find the guidelines here: http://stackoverflow.com/questions/6822000/when-to-use-uiinclude-tag-files-composite-components-and-or-custom-componen/6822269#6822269 Ultimately, just use the right tool for the job. – BalusC Sep 10 '13 at 18:13