You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Khlystov Alexandr <ak...@ovservice.org> on 2009/04/18 10:28:41 UTC

how to setup the @SpringBean for the WebSession?

Hi all!

Qustion: how to setup the @SpringBean for the WebSession?

I am folowing this guide: 
http://cwiki.apache.org/WICKET/spring.html#Spring-Using@SpringBeanbeyondWicket

I have defined a simple bean:
...
  <bean name="navigationManager" 
class="org.ovservice.hellowebapp.manager.NavigationManagerImpl">
    <property name="navigationDao">
      <ref bean="navigationDao" />
    </property>
  </bean>
...
and at WebApplication code:
...
    protected void init() {
        super.init();
        addComponentInstantiationListener(new 
SpringComponentInjector(this));
...

it works correctly for WebPage:
...
public class Left3ColumnPanel extends Panel{

    @SpringBean(name="navigationManager")
    private NavigationManager navigationManager;
...

but it doesn't work for session:
...
public class HelloWebappWebSession extends AuthenticatedWebSession{
...
    @SpringBean(name="navigationManager")
    private NavigationManager navigationManager;
...

I've got the

java.lang.NullPointerException
     at org.ovservice.hellowebapp.web.HelloWebappWebSession.authenticate(HelloWebappWebSession.java:47)


How can I use beans in WebSession? and maybe in some classes which are 
not the Wicket components.

Thanks in advance!



-- 
Khlystov Alexandr


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


Re: how to setup the @SpringBean for the WebSession?

Posted by Khlystov Alexandr <ak...@ovservice.org>.
Thanks Cristi!

It works, and also I've found that it is usual way seeing the javadoc 
for : SpringComponentInjector
Cristi Manole пишет:
> Hello,
>
> Can you try adding this to the WebSession constructor (or before actually
> using the bean) :
>
> InjectorHolder.getInjector().inject(this);
>
> I don't know if this is the usual way of doing things, but it works for me.
>
> Cristi Manole
>
> On Sat, Apr 18, 2009 at 11:28 AM, Khlystov Alexandr <ak...@ovservice.org>wrote:
>
>   
>> Hi all!
>>
>> Qustion: how to setup the @SpringBean for the WebSession?
>>
>> I am folowing this guide:
>> http://cwiki.apache.org/WICKET/spring.html#Spring-Using@SpringBeanbeyondWicket
>>
>> I have defined a simple bean:
>> ...
>>  <bean name="navigationManager"
>> class="org.ovservice.hellowebapp.manager.NavigationManagerImpl">
>>   <property name="navigationDao">
>>     <ref bean="navigationDao" />
>>   </property>
>>  </bean>
>> ...
>> and at WebApplication code:
>> ...
>>   protected void init() {
>>       super.init();
>>       addComponentInstantiationListener(new SpringComponentInjector(this));
>> ...
>>
>> it works correctly for WebPage:
>> ...
>> public class Left3ColumnPanel extends Panel{
>>
>>   @SpringBean(name="navigationManager")
>>   private NavigationManager navigationManager;
>> ...
>>
>> but it doesn't work for session:
>> ...
>> public class HelloWebappWebSession extends AuthenticatedWebSession{
>> ...
>>   @SpringBean(name="navigationManager")
>>   private NavigationManager navigationManager;
>> ...
>>
>> I've got the
>>
>> java.lang.NullPointerException
>>    at
>> org.ovservice.hellowebapp.web.HelloWebappWebSession.authenticate(HelloWebappWebSession.java:47)
>>
>>
>> How can I use beans in WebSession? and maybe in some classes which are not
>> the Wicket components.
>>
>> Thanks in advance!
>>
>>
>>
>> --
>> Khlystov Alexandr
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>     
>
>   


-- 
Khlystov Alexandr


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


Re: how to setup the @SpringBean for the WebSession?

Posted by Cristi Manole <cr...@gmail.com>.
Hello,

Can you try adding this to the WebSession constructor (or before actually
using the bean) :

InjectorHolder.getInjector().inject(this);

I don't know if this is the usual way of doing things, but it works for me.

Cristi Manole

On Sat, Apr 18, 2009 at 11:28 AM, Khlystov Alexandr <ak...@ovservice.org>wrote:

>
> Hi all!
>
> Qustion: how to setup the @SpringBean for the WebSession?
>
> I am folowing this guide:
> http://cwiki.apache.org/WICKET/spring.html#Spring-Using@SpringBeanbeyondWicket
>
> I have defined a simple bean:
> ...
>  <bean name="navigationManager"
> class="org.ovservice.hellowebapp.manager.NavigationManagerImpl">
>   <property name="navigationDao">
>     <ref bean="navigationDao" />
>   </property>
>  </bean>
> ...
> and at WebApplication code:
> ...
>   protected void init() {
>       super.init();
>       addComponentInstantiationListener(new SpringComponentInjector(this));
> ...
>
> it works correctly for WebPage:
> ...
> public class Left3ColumnPanel extends Panel{
>
>   @SpringBean(name="navigationManager")
>   private NavigationManager navigationManager;
> ...
>
> but it doesn't work for session:
> ...
> public class HelloWebappWebSession extends AuthenticatedWebSession{
> ...
>   @SpringBean(name="navigationManager")
>   private NavigationManager navigationManager;
> ...
>
> I've got the
>
> java.lang.NullPointerException
>    at
> org.ovservice.hellowebapp.web.HelloWebappWebSession.authenticate(HelloWebappWebSession.java:47)
>
>
> How can I use beans in WebSession? and maybe in some classes which are not
> the Wicket components.
>
> Thanks in advance!
>
>
>
> --
> Khlystov Alexandr
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>