[jsr-314-open] required attributes in composite components

Kito Mann kito.mann at VIRTUA.COM
Thu Apr 2 07:56:21 EDT 2009


So, here's one other thing that came up at JSFDays -- the fact that
composite components (like Facelet compositions) don't restrict which
attributes can be used. This is fine for Facelet compositions, but since
composite components can define specific attributes, it makes sense to give
component authors the ability to restrict page authors to those attributes.

I think the easiest way to handle this from a component author's perspective
would be to add an attribute to the <component:interface> tag:

<component:interface restrictAttributes="true">
  <component:attribute name="name" required="true"/>
  <component:attribute name="size"/>
</component:interface>

So, in this case, this component would _only_ accept the name and size
attributes, and the runtime would throw an exception if another attribute
were used. An IDE could also complain when someone tried to use a different
attribute.

Thoughts?
---
Kito D. Mann -- Author, JavaServer Faces in Action
http://twitter.com/kito99  http://twitter.com/jsfcentral
http://www.virtua.com - JSF/Java EE consulting, training, and mentoring
http://www.JSFCentral.com - JavaServer Faces FAQ, news, and info
+1 203-404-4848 x3

Public JSF Course in NYC (April 21st-24th):
http://www.regonline.com/jsf-course
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jsr-314-open-mirror/attachments/20090402/8e16e685/attachment.html 


More information about the jsr-314-open-mirror mailing list