Thanks for the reference.  I'm not sure how I missed that before.  I think I am going to try the wrapper bean idea.

Thanks for the help,
Michael

On 9/15/05, Mike Kienenberger <[EMAIL PROTECTED]> wrote:
It looks like you need to look at JavaServer Pages Specification (version 2.0),
sections 2.3 through 2.9 to determine the precedence of calling Map vs
calling Bean properties.

Take a look at JSF Spec 1.1 Section 5.1.3 (Get Value Semantics) and
5.1.4 (Set Value Semantics).   While nothing is explicitly stated for
get value semantics (just the reference to the above, which I don't
have handy), set value semantics show that the map put operation takes
precedence over the bean setter.

On 9/15/05, Michael <[EMAIL PROTECTED]> wrote:
> Yeah you can use expressions (JSF Spec 1.1 Section 10.3.1 Page 285).  I use
> Spring's delegating variable resolver to expose my Spring beans through EL
> and then I inject references to them in this manner.  It has worked great up
> until the map case.
>
>  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
> >
>
>

Reply via email to