You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Enrique Rodriguez <en...@gmail.com> on 2007/11/13 23:15:15 UTC

Injecting services into Resources using wicket-spring-annotations

Hi,

I have a web app where I'm using wicket-spring-annotations to inject
services into members of the Component hierarchy.  This works great.
I now find myself needing access to those services from within
DynamicWebResources.  IIUC, since Resources aren't part of the
Component hierarchy, they won't have SpringBean's set and, sure
enough, my services are null when I test this.

So, what is the recommended way to access services from
DynamicWebResources?  I could initialize the ApplicationContext from
within my WebApplication subclass and then acquire the needed bean and
inject it into the Resource at the time it is constructed and added to
the shared resources.  This wouldn't be a huge deal, but it would mean
moving some configuration from my various web.xml's into my
WebApplication subclass, so I wanted to check if I was missing
something or if support for SpringBean's in Resources was coming or
available in more recent versions of Wicket.

FYI, I'm using Wicket 1.2.6.  If this is a new feature in newer
versions the answer could be I need to update.

TIA,

Enrique

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Injecting services into Resources using wicket-spring-annotations

Posted by Enrique Rodriguez <en...@gmail.com>.
On Nov 13, 2007 3:02 PM, Igor Vaynberg <ig...@gmail.com> wrote:
> in the resource's constructor add this line:
>
> InjectorHolder.getInjector().inject(this);
>
> then you can use that class just like a component
>
> -igor

Thank you!  Of course, this worked perfectly.  I was happy to find I
could also pass parameters similar to the strategy employed by
mountBookmarkablePage.

Enrique

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Injecting services into Resources using wicket-spring-annotations

Posted by Igor Vaynberg <ig...@gmail.com>.
in the resource's constructor add this line:

InjectorHolder.getInjector().inject(this);

then you can use that class just like a component

-igor


On Nov 13, 2007 2:15 PM, Enrique Rodriguez <en...@gmail.com> wrote:
> Hi,
>
> I have a web app where I'm using wicket-spring-annotations to inject
> services into members of the Component hierarchy.  This works great.
> I now find myself needing access to those services from within
> DynamicWebResources.  IIUC, since Resources aren't part of the
> Component hierarchy, they won't have SpringBean's set and, sure
> enough, my services are null when I test this.
>
> So, what is the recommended way to access services from
> DynamicWebResources?  I could initialize the ApplicationContext from
> within my WebApplication subclass and then acquire the needed bean and
> inject it into the Resource at the time it is constructed and added to
> the shared resources.  This wouldn't be a huge deal, but it would mean
> moving some configuration from my various web.xml's into my
> WebApplication subclass, so I wanted to check if I was missing
> something or if support for SpringBean's in Resources was coming or
> available in more recent versions of Wicket.
>
> FYI, I'm using Wicket 1.2.6.  If this is a new feature in newer
> versions the answer could be I need to update.
>
> TIA,
>
> Enrique
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org