Hi,

Please create a ticket with a quickstart.
With a patch would be awesome!
Thanks!

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Tue, Jan 6, 2015 at 3:04 AM, RedCarpet <[email protected]> wrote:

> Spring 4 is able to wire/inject generic beans, as described here:
> http://spring.io/blog/2013/12/03/spring-framework-4-0-and-java-generics .
> However, I'm experiencing problems when using generic beans with Wicket's
> SpringBean.
>
> I basically have following situation, two concrete dao's that implement a
> generic typed interface dao.:
> class Product{}
> class Car extends Product{}
> class Phone extends Product{}
> interface ProductDao<T extends Product> {}
> class CarProductDao implements ProductDao<Car> {}
> class PhoneProductDao implements ProductDao<Phone> {}
>
> class ProductModel<T extends Product> extends LoadableDetachableModel<T> {
>  @SpringBean ProductDao<T> productDao;
> }
> class ProductPage extends WebPage {
>  ...
>  ProductModel<CarProduct> model = new ProductModel<CarProduct>(product);
>  ...
> }
>
> This will result in the following error:
> 2015-jan-06;01:53:23.471 http-nio-8080-exec-6 WARN  RequestCycleExtra -
> Handling the following exception
> java.lang.IllegalStateException: More than one bean of type [ProductDao]
> found, you have to specify the name of the bean (@SpringBean(name="foo"))
> or
> (@Named("foo") if using @javax.inject classes) in order to resolve this
> conflict. Matched beans: carProductDao,phoneProductDao
>         at
>
> org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.getBeanNameOfClass(AnnotProxyFieldValueFactory.java:289)
> ~[AnnotProxyFieldValueFactory.class:6.18.0]
>         at
>
> org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.getBeanName(AnnotProxyFieldValueFactory.java:198)
> ~[AnnotProxyFieldValueFactory.class:6.18.0]
>         at
>
> org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.getFieldValue(AnnotProxyFieldValueFactory.java:130)
> ~[AnnotProxyFieldValueFactory.class:6.18.0]
>         at org.apache.wicket.injection.Injector.inject(Injector.java:111)
> ~[Injector.class:6.18.0]
>         at
>
> org.apache.wicket.spring.injection.annot.SpringComponentInjector.inject(SpringComponentInjector.java:124)
> ~[SpringComponentInjector.class:6.18.0]
>         at ProductModel.<init>(ProductModel.java:20)
> ~[ProductModel.class:na]
>         at ProductPage$15.populateItem(ProductPage.java:742)
> ~[ProductPage$15.class:na]
>
>
>
> Does Wicket's SpringBean support Spring-4's generics support?
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/SpringBean-doesn-t-support-Generics-tp4668928.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to