I've been searched how to parametrize the Managed Bean class, and until now nothing.
What I'm doing?
I have a JSF component that access some methods from my Bean, but this methods are already implemented by an abstract Class.
The name of the methods and attributes don't change, but now I'm copying and pasting, changing only the Bean name.
The first implementation is work, but I would like to improve with the second one.
1- Component (Now):
...
<cc:interface>
<cc:attribute name="title" type="java.lang.String" required="true"/>
<cc:attribute name="data" type="java.util.List" required="true"/>
<cc:attribute name="columnModel" type="java.util.List" required="true"/>
<cc:attribute name="newEntity" type="java.lang.Object" required="true"/>
<cc:attribute name="crudState" type="java.lang.Integer" required="true"/>
</cc:interface>
...
<cc:implementation>
<p:dataTable var="entity" value="#{cc.attrs.data}" >
<p:columns value="#{cc.attrs.columnModel}"
var="column" style="#{column.style}"
styleClass="#{column.styleClass}">
...
</p:columns>
</p:dataTable>
</cc:implementation>
...
1- Implementations (Now):
...
<comp:crud
title="#{cfgUserBean.title}"
data="#{cfgUserBean.data}"
columnModel="#{cfgUserBean.coluuns}"
newEntity="#{cfgUserBean.newEntity}"
newEntity="#{cfgUserBean.crudState}"/>
...
<comp:crud
title="#{cfgCityBean.title}"
data="#{cfgCityBean.data}"
columnModel="#{cfgCityBean.columns}"
newEntity="#{cfgCityBean.newEntity}"
crudState="#{cfgCityBean.curdState}"/>
Desired:
Pass the Bean Name as a Parameter
2- Component (Desired):
...
<cc:interface>
<cc:attribute name="BEANNAME" type="java.lang.Object" required="true"/>
</cc:interface>
...
<cc:implementation>
<p:dataTable var="entity" value="#{cc.attrs.BEANNAME.data}" >
<p:columns value="#{cc.attrs.BEANNAME.columnModel}"
var="column" style="#{column.style}"
styleClass="#{column.styleClass}">
...
</p:columns>
</p:dataTable>
</cc:implementation>
2- Implementations (Desired):
...
<comp:crud BEANNAME="cfgUserBean" />
...
<comp:crud BEANNAME="cfgCityBean" />
Conclusion
As you can see, If I could parametrize the Bean name, I would be able to simplify a lot the final coding.
Any one with any Idea what I could do? Thank you in advance