You could also define your WicketApplication in your spring config by setting the applicationFactoryClassName property of the WicketFilter to org.apache.wicket.spring.SpringWebApplicationFactory. This way you don't have to manually inject your dependencies via the InjectorHolder. The only thing is then that you don't have to use the @SpringBean annotation anymore.
On Tue, Apr 8, 2008 at 11:08 AM, Korbinian Bachl - privat < [EMAIL PROTECTED]> wrote: > Ah, shame on me! youre right - in case of extending SpringWebApplication > it works; in case of ext. WebApplication it wont work - thats what I mixed > up - but only if not using @SpringBean but the get direct; > > thx for info Daniel, > > Regards, > > Korbinian > > Daniel Stoch schrieb: > > Hi, > > > > I think he can :). > > SpringWebApplication is not a Component so this: > > addComponentInstantiationListener(new SpringComponentInjector(this)); > > doesn't matter here. > > > > Before you want to use this @SpringBean in your init() method you should > > call: > > InjectorHolder.getInjector().inject(this); > > > > But then you should use AnnotSpringWebApplication or "manually" setup > > injector in InjectorHolder: > > InjectorHolder.setInjector(new > > AnnotSpringInjector(getSpringContextLocator())); > > > > -- > > Daniel > > > > On Tue, Apr 8, 2008 at 10:19 AM, Korbinian Bachl - privat > > <[EMAIL PROTECTED]> wrote: > > > > > Hi Mathias, > > > > > > in short: you cant; > > > > > > the @SpringBean injection is usually done before the class is really > > > created so at a time wicket and spring aren't registered yet; > > > > > > What you could do (not 100% sure) would be to call a simple > > > proxy-pojo that > > > gets you the data (even maybe a LoadableDetachable one?) during > > > startup - so > > > the firs request to @SpringBean is done after the creation and > > > initalisation > > > of the application class (and the line with the > > > SpringComponentInjector). > > > > > > Maybe it could also try to use your needed bean without the spring > > > call but > > > instantiate it directly? > > > > > > Best, > > > > > > Korbinian > > > > > > Mathias P.W Nilsson schrieb: > > > > > > > > > Hi! > > > > > > > > I have extended the SpringWebApplication and the init method looks > > > > like > > > > > > > > addComponentInstantiationListener(new > > > > SpringComponentInjector(this)); > > > > > > > > > > > > I want to access my @SpringBean in the init method but it fails. How > > > > can I > > > > do this? I need to cache > > > > all users from a webservice in application startup. > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > 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] > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >