Is there a way of setting a managed bean parameter in a composite component and then leaving the using classes to decide which actual managed bean to use?
something along the lines of: comp.xhtml
<cc:interface>
<cc:attribute name="price" />
<cc:param name="pageBean" value="#{superBean}" />
<cc:interface>
<cc:implementation>
<h:outputText value="#{cc.attrs.price}"/>
</cc:implementation>
And then, in the using page
<ezcomp:comp pageBean="actualBean"
price="#{actualBean.price}" >
</ezcomp:comp>
In my case ActualBean is a subtype of SuperBean.
I'm not even sure this is possible, but let's just say it would be great if someone proved me wrong.
Thank you in advance
To remove duplicate code, basically. i have a lot of attributes that need to be set in the composite component. The only thing that differs in the using pages is the name of the managed beans, all being subtypes of a superbean.
You don't need to specify all the attributes. Just specifying alone the bean is sufficient. You could reference its properties in the composite component directly.
<cc:interface>
<cc:attribute name="pageBean" type="com.example.SuperBean" required="true" />
<cc:interface>
<cc:implementation>
<h:outputText value="#{cc.attrs.pageBean.price}"/>
</cc:implementation>
with
<ezcomp:comp pageBean="#{actualBean}" />
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