I need to verify whether an optional attribute has been passed or not within my composite component. How can I achieve this?
<composite:interface>
<composite:attribute name="attr1" />
<composite:attribute name="attr2" required="false" /> <!-- means OPTIONAL -->
</composite:interface>
<composite:implementation>
<!-- How I can verify here whether attr2 is present or not whenever this component is used? -->
</composite:implementation>
Setting the default
attribute to xxx
for <composite:attribute>
is not what I'm looking for.
You could just check if #{not empty cc.attrs.attr2}
evaluates to true
.
E.g. inside the rendered
attribute of an arbitrary component:
<composite:implementation>
<h:panelGroup rendered="#{not empty cc.attrs.attr2}">
Attribute attr2 is not empty!
</h:panelGroup>
</composite:implementation>
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