In the composite:interface I have defined an attribute like this:
<composite:attribute name="myAttribute" required="true"/>
Now when I use my composite component like this, without defining any attributes:
<myTag:myCC/>
I would expect an error to occur. It doesn't. What could I possibly be missing?
It will only occur if your JSF project stage is set to Development
as follows in web.xml
:
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
It defaults to Production
. Don't be surprised if you start to see several other errors/warnings related to "development mistakes" after setting the above context parameter.
In your specific case you should get an exception during opening the page something like this when you omit the required attribute:
javax.faces.view.facelets.TagException: /test.xhtml @22,19 <my:composite> The following attribute(s) are required, but no values have been supplied for them: foo.
at com.sun.faces.facelets.tag.composite.InterfaceHandler.validateComponent(InterfaceHandler.java:232)
at com.sun.faces.facelets.tag.composite.InterfaceHandler.apply(InterfaceHandler.java:125)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:95)
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With