I found one way to fix this problem. But I am not sure if that is good one.
(1) create one class to implement ObjectProvider
public class TapestrySpringBeanProvider implements ObjectProvider {



    @Override
    public <T> T provide(Class<T> clazz, AnnotationProvider ap,
            ObjectLocator locator) {
        // you can use any annotation you like
        Id id = ap.getAnnotation(Id.class);
        if ( id == null )
            return null;
        String beanName = id.value();
        ApplicationContext context =
locator.getService(ApplicationContext.class);
        return (T) context.getBean(beanName);
    }

}

(2) from your module class, add following method:

     public static void
contributeMasterObjectProvider(OrderedConfiguration<ObjectProvider> config){
         config.override("SpringBean",new TapestrySpringBeanProvider());
     }

(3) inject your spring bean like
@Inject
@Id("beanId")
private BaseDAO baseDAO

It works for me now.

On Wed, Jun 17, 2009 at 1:40 AM, Otho <taa...@googlemail.com> wrote:

> I had a similar problem. Maybe this thread helps you:
>
>
> http://www.nabble.com/T-5.1-How-to-inject-Spring-beans-by-name--td22934788.html
>
> 2009/6/17 haipeng du <haipen...@gmail.com>
>
> > I try to inject spring beans to page class with
> > @Inject
> > @Id("baseDAO")
> > private BaseDAO baseDAO
> >
> > It still gave me that "Spring context contains 14 beans assignable to
> type
> > xx.BaseDAO
> >
> > what should I do for this.
> >
> > --
> > Haipeng Du
> > Salt Lake City
> >
>



-- 
Haipeng Du
Salt Lake City

Reply via email to