You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Bert Radke <ta...@gmail.com> on 2008/02/29 10:54:41 UTC

SpringBean in AuthenticatedWebSession

Hi List,

thanks to the help i received so far here, i managed to load objects
through JPA using DAOs.
The DAOs get injected just fine using the wicket-spring extension (i
used the blog example [1]
as a starting point). So this is all fine, but now i tried using the
same technique to load and
verify a user for login purposes, but the userDao does not get injected.

My Session extends AuthenticatedWebSession and is created fine, but no
DAO is injected.

	@SpringBean(name = "userDao")
	private UserDao dao;

the "userDao" is defined in the application.xml just like all the others...

Do i have to take any additional steps to get Spring to inject the DAO
into the session?

[1] http://cwiki.apache.org/WICKET/blog-tutorial.html

Thanks in advance for your time.
Bert

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


Re: SpringBean in AuthenticatedWebSession

Posted by lars vonk <la...@gmail.com>.
If I recall it correctly only Components are injected. A Session is
not a Component and therefor not injected.

You could pass the UserDao as construtor argument yourself when
instantiating you Session class in your newSession method in your
WebApplication.

Lars



On Fri, Feb 29, 2008 at 10:54 AM, Bert Radke <ta...@gmail.com> wrote:
> Hi List,
>
>  thanks to the help i received so far here, i managed to load objects
>  through JPA using DAOs.
>  The DAOs get injected just fine using the wicket-spring extension (i
>  used the blog example [1]
>  as a starting point). So this is all fine, but now i tried using the
>  same technique to load and
>  verify a user for login purposes, but the userDao does not get injected.
>
>  My Session extends AuthenticatedWebSession and is created fine, but no
>  DAO is injected.
>
>         @SpringBean(name = "userDao")
>         private UserDao dao;
>
>  the "userDao" is defined in the application.xml just like all the others...
>
>  Do i have to take any additional steps to get Spring to inject the DAO
>  into the session?
>
>  [1] http://cwiki.apache.org/WICKET/blog-tutorial.html
>
>  Thanks in advance for your time.
>  Bert
>
>  ---------------------------------------------------------------------
>  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


Re: SpringBean in AuthenticatedWebSession

Posted by lars vonk <la...@gmail.com>.
Nice one Sebastiaan. Only now I have to refactor my code.... :-)

On Fri, Feb 29, 2008 at 11:52 AM, Bert Radke <ta...@gmail.com> wrote:
> Thank you,
>
>  while trying the approach from Lars, your answer came in ;)
>
>
>  On Fri, Feb 29, 2008 at 11:33 AM, Sebastiaan van Erk
>  <se...@sebster.com> wrote:
>  > One option is to add:
>  >
>  >  InjectorHolder.getInjector().inject(this)
>  >
>  I should have know this myself, as it came up on this list recently..
>
>  But now it works,
>
>  Thank you both.
>
>
>
>  Bert
>
>  ---------------------------------------------------------------------
>  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


Re: SpringBean in AuthenticatedWebSession

Posted by Bert Radke <ta...@gmail.com>.
Thank you,

while trying the approach from Lars, your answer came in ;)

On Fri, Feb 29, 2008 at 11:33 AM, Sebastiaan van Erk
<se...@sebster.com> wrote:
> One option is to add:
>
>  InjectorHolder.getInjector().inject(this)
>
I should have know this myself, as it came up on this list recently..

But now it works,

Thank you both.

Bert

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


Re: SpringBean in AuthenticatedWebSession

Posted by Sebastiaan van Erk <se...@sebster.com>.
One option is to add:

InjectorHolder.getInjector().inject(this)

In your session constructor.

Regards,
Sebastiaan

Bert Radke wrote:
> Hi List,
> 
> thanks to the help i received so far here, i managed to load objects
> through JPA using DAOs.
> The DAOs get injected just fine using the wicket-spring extension (i
> used the blog example [1]
> as a starting point). So this is all fine, but now i tried using the
> same technique to load and
> verify a user for login purposes, but the userDao does not get injected.
> 
> My Session extends AuthenticatedWebSession and is created fine, but no
> DAO is injected.
> 
> 	@SpringBean(name = "userDao")
> 	private UserDao dao;
> 
> the "userDao" is defined in the application.xml just like all the others...
> 
> Do i have to take any additional steps to get Spring to inject the DAO
> into the session?
> 
> [1] http://cwiki.apache.org/WICKET/blog-tutorial.html
> 
> Thanks in advance for your time.
> Bert
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>