My abstract basewebmodel constructor from which all my webmodels inherit marks inself for Spring injection but still no injection takes place. Any suggestions where I can look?
Can I run the injection in the constructor of an abstract model from which I inherit all my webmodels? I cannot see why not? Thanks in advanced. P BaseWebModel.java ================= ... public BaseWebModel(Long id) { this.id = id; InjectorHolder.getInjector().inject(this); } here is an example of my TemplateWebModel that uses @SpringBean to set TemplateFactory TemplateWebModel.java =================== ... @SpringBean(name="TemplateFactory") private TemplateFactory templateFactory; public TemplateWebModel(Template template) { super(template); } P On Fri, Sep 11, 2009 at 10:42 AM, jWeekend <jweekend_for...@cabouge.com>wrote: > > Pieter, > > If you want to use Spring's @Configuarble you'll need to enable Load Time > Weaving or Complie Time Weaving. > > To use @SpringBean with an object that is not a Wicket Component you need > to > InjectorHolder.getInjector().inject(this) on initialisation of your object. > > The benefit of the latter approach is that you do not need to introduce > weaving and that Wicket will make sure you have a serialisable proxy > injected. > > Regards - Cemal > jWeekend > OO & Java Technologies, Wicket Training and Development > http://jWeekend.com > > > > > Pieter Claassen wrote: > > > > I am using maven, spring 2.5.6, wicket 1.4 and am trying to inject my > > DAO's > > into my wicket models but I find that Spring just ignores my advice. > > > > My question: > > 1. @SpringBean only works on stuff that inherits from Component. What do > I > > do with things like session and models that don't? I am trying to use > > @Configurable but that is being ignored. > > 2. My POM deps are below. What should I pull in to have @Configurable > > working? > > 3. BTW. When I comment the bean out of my XML config, then I do get an > > error > > so I am not sure if I am doing something very small wrong? > > > > Thanks. > > Pieter > > > > pom.xml > > ======= > > ... > > <dependency> > > <groupId>org.springframework</groupId> > > <artifactId>spring-core</artifactId> > > <version>${spring.version}</version> > > </dependency> > > > > <dependency> > > <groupId>org.apache.wicket</groupId> > > <artifactId>wicket-spring</artifactId> > > <version>${wicket.version}</version> > > <!--Same results whether I include or exclude the next session--> > > <exclusions> > > <exclusion> > > <groupId>org.springframework</groupId> > > <artifactId>spring</artifactId> > > </exclusion> > > </exclusions> > > </dependency> > > .... > > > > > > TemplateWebModel.java > > ================== > > ..... > > @Configurable > > public class TemplateWebModel extends AbstractDataSetWebModel<Template> { > > > > private TemplateFactory templateFactory; > > > > public TemplateFactory getTemplateFactory() { > > return templateFactory; > > } > > > > public void setTemplateFactory(TemplateFactory templateFactory) { > > throw new RuntimeException("REACHED TEMPLATE FACTORY SET"); //This > > setter is never run!!!! > > //this.templateFactory = templateFactory; > > } > > ..... > > > > WicketApplicationDefinitition.xml > > ========================== > > > > <?xml version="1.0" encoding="UTF-8"?> > > <beans xmlns="http://www.springframework.org/schema/beans" > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > > xmlns:context="http://www.springframework.org/schema/context" > > xsi:schemaLocation=" > > http://www.springframework.org/schema/beans > > http://www.springframework.org/schema/beans/spring-beans-2.5.xsd > > http://www.springframework.org/schema/context > > http://www.springframework.org/schema/context/spring-context-2.5.xsd"> > > > > <context:annotation-config/> > > <!--<aop:aspectj-autoproxy/>--> > > > > <!-- a bean that supplies my primary application database client --> > > <bean id="appDataSource" class="com.musmato.dao.ApplicationDBFactory" > > destroy-method="close"> > > <constructor-arg> > > <ref bean="appConfig" /> > > </constructor-arg> > > </bean> > > > > <!-- a bean that supplies a network database client for template uploads > > --> > > <bean id="rootDataSource" class="com.musmato.dao.RootDBFactory" > > destroy-method="close"> > > <constructor-arg> > > <ref bean="appConfig" /> > > </constructor-arg> > > </bean> > > ..... > > <bean id="TemplateFactory" class="com.musmato.dao.TemplateFactory"> > > <property name="client" ref="appDataSource" /> > > </bean> > > .... > > > > > > > > > > > > -- > > Pieter Claassen > > musmato.com > > > > > > -- > View this message in context: > http://www.nabble.com/Spring-annotations-fail-to-inject-into-webmodels-tp25396625p25397205.html > Sent from the Wicket - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > -- Pieter Claassen musmato.com