Should a bug be filed on this or is it desired behavior? I looked through the spec for guidance here but I didn't see anything.
Thanks,
Michael
On 9/15/05, "Ricardo R. RamÃrez Valenzuela" <[EMAIL PROTECTED]> wrote:
Does this actually work? I don't think you can use expressions in the
value for initialization.
What I do when I want to "inject" a value to another bean is get the
bean via the faces context, for example I do a
getManagedBean("detailsBean").setDetail(someObject)
(I attach the code for my getManagedBean method below)
public final static Object getManagedBean(String beanName)
{
FacesContext facesContext = FacesContext.getCurrentInstance();
Application a = facesContext.getApplication();
ValueBinding binding = a.createValueBinding("#{" + beanName + "}");
return binding.getValue (facesContext);
}
I wonder if this is the best practice....
Ricardo
Michael wrote:
> Hi all,
>
> I have a managed bean that implements the Map interface. The bean
> also has a dependency that needs to be injected. I thought I'd be
> able to configure the bean like this:
>
> public class MyMap implements Map {
> ...
> public Dependency getMyDependency() {
> return myDependency;
> }
> public Dependency setMyDependency(Dependency newDependency) {
> myDependency = newDependency;
> // initialize contained map using myDependency
> }
> ...
> // Impementation of map interface...
> }
>
> <managed-bean>
> <managed-bean-name>myMap</managed-bean-name>
> <managed-bean-class>MyMap</managed-bean-class>
> <managed-bean-scope>request</managed-bean-scope>
> <managed-property>
> <property-name>myDependency</property-name>
> <property-class>Dependency</property-class>
> <value>#{someOtherBean}</value>
> </managed-property>
> </managed-bean>
>
> The problem I'm running into is that PropertyResolverImpl.setValue
> checks to see if the bean is an instance of Map and if so, calls
> put(property, value). So instead of calling MyMap.setMyDependency, it
> is calling MyMap.put and passing the key = "myDependency" and the
> value = #{someOtherBean}.
>
> Any suggestions?
>
> Thanks,
> Michael