You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by CrocodileShoes <ma...@googlemail.com> on 2009/03/04 22:59:53 UTC

How can I injecting a Springbean into a custom session.

Apologies if this is more of a Spring question than a Wicket question, I'm
just not sure.

Anyway, the problem.  

I have a custom session class which inherits form WebSession.  I've
overridden the WebApplication's newSession() method in order to return a new
instance of my custom session.  However I want my custom session to use a
Springbean but because the Spring container didn't create the custom session
object it can't inject the dependency.

Does anybody know how to get around this or if it's possible.  It could be
that my design is flawed ;D
-- 
View this message in context: http://www.nabble.com/How-can-I-injecting-a-Springbean-into-a-custom-session.-tp22340379p22340379.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: How can I injecting a Springbean into a custom session.

Posted by Leszek Gawron <lg...@apache.org>.
CrocodileShoes wrote:
> By the way is this safe to use in any Wicket component, for example, a Panel?
> 
> I can't think of any reason why not, but this is my first foray into web
> development.

Yes it is. @SpringBean creates a proxy to your spring bean so there are 
no serialization issues.

-- 
Leszek Gawron

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


Re: How can I injecting a Springbean into a custom session.

Posted by Igor Vaynberg <ig...@gmail.com>.
you still have to do it, that is what enables @SpringBean inside components

-igor

On Fri, Mar 6, 2009 at 11:32 AM, Warren Bell <wa...@gmail.com> wrote:

> Do you still have to use addComponentInstantiationListener(new
> SpringComponentInjector(this)) in your WebApplication#init() in order to use
> @SpringBean in sub classes of Component or is that done automatically now?
>
> Warren
>
>
>
> Igor Vaynberg wrote:
>
>  all subclasses of Component are injected automatically, you only need to
>> do
>> this in classes outside the Component hierarchy.
>>
>> -igor
>>
>> On Fri, Mar 6, 2009 at 9:32 AM, CrocodileShoes <
>> markjohndoyle@googlemail.com
>>
>>
>>> wrote:
>>>
>>>
>>
>>
>>
>>> By the way is this safe to use in any Wicket component, for example, a
>>> Panel?
>>>
>>> I can't think of any reason why not, but this is my first foray into web
>>> development.
>>> --
>>> View this message in context:
>>>
>>> http://www.nabble.com/How-can-I-inject-a-Springbean-into-a-custom-session.-tp22340379p22377028.html
>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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: How can I injecting a Springbean into a custom session.

Posted by Warren Bell <wa...@gmail.com>.
Do you still have to use addComponentInstantiationListener(new 
SpringComponentInjector(this)) in your WebApplication#init() in order to 
use @SpringBean in sub classes of Component or is that done 
automatically now?

Warren


Igor Vaynberg wrote:

> all subclasses of Component are injected automatically, you only need to do
> this in classes outside the Component hierarchy.
>
> -igor
>
> On Fri, Mar 6, 2009 at 9:32 AM, CrocodileShoes <markjohndoyle@googlemail.com
>   
>> wrote:
>>     
>
>   
>> By the way is this safe to use in any Wicket component, for example, a
>> Panel?
>>
>> I can't think of any reason why not, but this is my first foray into web
>> development.
>> --
>> View this message in context:
>> http://www.nabble.com/How-can-I-inject-a-Springbean-into-a-custom-session.-tp22340379p22377028.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> 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: How can I injecting a Springbean into a custom session.

Posted by Igor Vaynberg <ig...@gmail.com>.
all subclasses of Component are injected automatically, you only need to do
this in classes outside the Component hierarchy.

-igor

On Fri, Mar 6, 2009 at 9:32 AM, CrocodileShoes <markjohndoyle@googlemail.com
> wrote:

>
> By the way is this safe to use in any Wicket component, for example, a
> Panel?
>
> I can't think of any reason why not, but this is my first foray into web
> development.
> --
> View this message in context:
> http://www.nabble.com/How-can-I-inject-a-Springbean-into-a-custom-session.-tp22340379p22377028.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: How can I injecting a Springbean into a custom session.

Posted by CrocodileShoes <ma...@googlemail.com>.
By the way is this safe to use in any Wicket component, for example, a Panel?

I can't think of any reason why not, but this is my first foray into web
development.
-- 
View this message in context: http://www.nabble.com/How-can-I-inject-a-Springbean-into-a-custom-session.-tp22340379p22377028.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: How can I injecting a Springbean into a custom session.

Posted by CrocodileShoes <ma...@googlemail.com>.
Thanks, Igor; this worked perfectly.
-- 
View this message in context: http://www.nabble.com/How-can-I-injecting-a-Springbean-into-a-custom-session.-tp22340379p22350445.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: How can I injecting a Springbean into a custom session.

Posted by Igor Vaynberg <ig...@gmail.com>.
class mysession {
@SpringBean private dao;

  public mysession(...) {
      super(...);
      InjectorHolder.getInjector().inject(this);
  }
}

-igor

On Wed, Mar 4, 2009 at 1:59 PM, CrocodileShoes
<ma...@googlemail.com> wrote:
>
> Apologies if this is more of a Spring question than a Wicket question, I'm
> just not sure.
>
> Anyway, the problem.
>
> I have a custom session class which inherits form WebSession.  I've
> overridden the WebApplication's newSession() method in order to return a new
> instance of my custom session.  However I want my custom session to use a
> Springbean but because the Spring container didn't create the custom session
> object it can't inject the dependency.
>
> Does anybody know how to get around this or if it's possible.  It could be
> that my design is flawed ;D
> --
> View this message in context: http://www.nabble.com/How-can-I-injecting-a-Springbean-into-a-custom-session.-tp22340379p22340379.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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