Maybe this is too simple but:
Did you define this bean in the applicationContext.xml?:
<bean id="myobj" class="{impl. class}">{possible properties}</bean>
And usually when I'm dealing with are objects that aren't wicket components,
like models or the WebApplication object itself, I have to inject them.
In a WebApplication Object:
getComponentInstantiationListeners().add(new SpringComponentInjector(this));
In a model:
Injector.get().inject(this);
Cheers,
Marco
On Saturday 11 May 2013 11:21:38 smallufo wrote:
> I try to do this in init() :
>
> ctx.getAutowireCapableBeanFactory().configureBean(obj, "myobj");
> or
> ctx.getAutowireCapableBeanFactory().applyBeanPostProcessorsAfterInitializati
> on(obj, "myobj");
> or
> ctx.getAutowireCapableBeanFactory().applyBeanPostProcessorsBeforeInitializat
> ion(obj, "myobj");
>
> But in a WebPage with a @SpringBean(name="myobj") private IMyObj myobj;
> I still get NoSuchBeanDefinitionException error ...
>
>
>
> 2013/5/11 smallufo <[email protected]>
>
> > Hi
> > Is there any code example to create beans and register to spring ?
> > I can get ApplicationContext
> > by
> > WebApplicationContextUtils.getRequiredWebApplicationContext(getServletCon
> > text()); but there is no setter or register or createBean methods
> > within...
> >
> > Or use of factory bean ?
> > I searched FactoryBean , got the idea behind it . But I still don't know
> > how to do it in wicket ?
> >
> > Thanks.
> >
> >
> > 2013/5/11 Igor Vaynberg <[email protected]>
> >
> >> see spring's FactoryBean, its an indirect way to create beans.
> >>
> >> -igor
> >>
> >> On Fri, May 10, 2013 at 12:33 PM, smallufo <[email protected]> wrote:
> >> > Hi , I wonder if it possible to programmatically create / register a
> >>
> >> spring
> >>
> >> > bean in wicket?
> >> > maybe in Application.init() ...
> >> >
> >> > Most documents about spring are "making use of existent beans" , and
> >>
> >> inject
> >>
> >> > to WebPage or Panel via @SpringBean , and it indeed works well.
> >> >
> >> > But my interface implementations are depend on wicket-component ,
> >> > such as getting absolute URL of a page or a DynamicImageResource
> >> >
> >> > So these beans should be initialized and register to Spring in init()
> >> > (correct me if I am wrong)
> >> >
> >> > Any way to achieve this ?
> >> >
> >> > Thanks.
> >> >
> >> > (I am using wicket 6.7 )
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [email protected]
> >> For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]