I have a ManagedBean say clsA, inside this clsA has a BOC object that will fill with DI. If I want to invoke the BOC during clsA construction, I will do it in clsA constructor. The code will look like this:
@ManagedBean(name="clsA")
public class ClsA {
private BOC boc;
public clsA(BOC theBoc) {
theBoc.doFuncA();
}
public String doFuncD() { return ""; }
}
And the Spring configuration will have this:
<bean id="theBoc" class="com.foo.BOC"/>
<bean id="clsA" class="com.foo.clsA">
<constructor-arg value="theBoc"/>
</bean>
Now I found a problem that if I have the clsA
bean declare inside Spring configuration, my JSF bean, clsA
, which is also same name with the one declare inside Spring configuration, will not work. Meaning that if I invoke the doFuncD()
from JSF, it is not get call. If I remove the clsA
Spring declaration, the JSF bean clsA
is working fine.
Is there a better way to invoke BOC from managedBean ClsA
constructor?