Re: Spring annotations fail to inject into webmodels
= >>> > ... >>> > >>> > org.springframework >>> > spring-core >>> > ${spring.version} >>> > >>> > >>> > >>> > org.apache.wicket >>> > wicket-spring >>> > ${wicket.version} >>> > >>> > >>> > >>> > org.springframework >>> > spring >>> > >>> > >>> > >>> > >>> > >>> > >>> > TemplateWebModel.java >>> > == >>> > . >>> > @Configurable >>> > public class TemplateWebModel extends >>> AbstractDataSetWebModel { >>> > >>> > 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 >>> > == >>> > >>> > >>> > 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";> >>> > >>> > >>> > >>> > >>> > >>> > >> class="com.musmato.dao.ApplicationDBFactory" >>> > destroy-method="close"> >>> > >>> > >>> > >>> > >>> > >>> > >>> > >> > destroy-method="close"> >>> > >>> > >>> > >>> > >>> > . >>> > >> class="com.musmato.dao.TemplateFactory"> >>> > >>> > >>> > >>> > >>> > >>> > >>> > >>> > >>> > -- >>> > 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 >> >> > > -- View this message in context: http://www.nabble.com/Spring-annotations-fail-to-inject-into-webmodels-tp25396625p25413489.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
Re: Spring annotations fail to inject into webmodels
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 >> > == >> > >> > >> > 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";> >> > >> > >> > >> > >> > >> > > class="com.musmato.dao.ApplicationDBFactory" >> > destroy-method="close"> >> > >> > >> > >> > >> > >> > >> > > > destroy-method="close"> >> > >> > >> > >> > >> > . >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > -- >> > 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 > > -- View this message in context: http://www.nabble.com/Spring-annotations-fail-to-inject-into-webmodels-tp25396625p25413472.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
Re: Spring annotations fail to inject into webmodels
Did you add the listener to your spring context ? class="org.apache.wicket.injection.ComponentInjector"/> On 12 sep 2009, at 11:53, pieter claassen wrote: 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 >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 === ... org.springframework spring-core ${spring.version} org.apache.wicket wicket-spring ${wicket.version} org.springframework spring TemplateWebModel.java == . @Configurable public class TemplateWebModel extends AbstractDataSetWebModel { 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 == 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"> class="com.musmato.dao.ApplicationDBFactory" destroy-method="close"> . class="com.musmato.dao.TemplateFactory"> -- 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 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Spring annotations fail to inject into webmodels
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 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 > > === > > ... > > > > org.springframework > > spring-core > > ${spring.version} > > > > > > > > org.apache.wicket > > wicket-spring > > ${wicket.version} > > > > > > > > org.springframework > > spring > > > > > > > > > > > > > > TemplateWebModel.java > > == > > . > > @Configurable > > public class TemplateWebModel extends AbstractDataSetWebModel { > > > > 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 > > == > > > > > > 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";> > > > > > > > > > > > > > destroy-method="close"> > > > > > > > > > > > > > > > destroy-method="close"> > > > > > > > > > > . > > > > > > > > > > > > > > > > > > > > -- > > 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
Re: Spring annotations fail to inject into webmodels
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 > === > ... > > org.springframework > spring-core > ${spring.version} > > > > org.apache.wicket > wicket-spring > ${wicket.version} > > > > org.springframework > spring > > > > > > > TemplateWebModel.java > == > . > @Configurable > public class TemplateWebModel extends AbstractDataSetWebModel { > > 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 > == > > > 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";> > > > > > > destroy-method="close"> > > > > > > > destroy-method="close"> > > > > > . > > > > > > > > > > -- > 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
Spring annotations fail to inject into webmodels
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 === ... org.springframework spring-core ${spring.version} org.apache.wicket wicket-spring ${wicket.version} org.springframework spring TemplateWebModel.java == . @Configurable public class TemplateWebModel extends AbstractDataSetWebModel { 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 == 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";> . -- Pieter Claassen musmato.com