You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Tim Koop <ti...@timkoop.com> on 2010/12/29 20:37:52 UTC
Inject Cookies into a SessionState object
I have a class I call UserDetails, which is a SessionState object. I
use it like this on a component page:
@SessionState
private UserDetails userDetails;
However, in my UserDetails class I want to retrieve Cookies like this:
@Inject
private Cookies cookies;
But I don't think you can inject Tapestry objects on a non-component or
non-page object, can you?
Any ideas?
Thanks.
--
Tim Koop
tim@timkoop.com <ma...@timkoop.com>
www.timkoop.com <http://www.timkoop.com>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Inject Cookies into a SessionState object
Posted by Bryan Lewis <jb...@gmail.com>.
Cool! (This new-fangled IOC stuff feels like black magic to someone who cut
his teeth on Tapestry 3. Not to mention WebObjects in the previous
century. Keep the faith, baby!)
On Wed, Dec 29, 2010 at 3:28 PM, Thiago H. de Paula Figueiredo <
thiagohp@gmail.com> wrote:
> You don't even need the @InjectService or @Inject annotations for injection
> to be done in constructors of services.
>
> Naming your session state class Visit makes me 99% sure you were a Tapestry
> 4 or 3 user. :P
>
>
> On Wed, 29 Dec 2010 18:19:12 -0200, Bryan Lewis <jb...@gmail.com>
> wrote:
>
> Here's what's been working for us, constructor injecion. (My syntax might
>> be a bit old and deprecated by now?)
>>
>>
>> public Visit(@InjectService("Cookies") Cookies cookieService)
>> {
>> this.cookieService = cookieService;
>> }
>>
>> // Just to make sure I don't try to do 'new Visit()', hide this
>> constructor.
>> private Visit()
>> {
>> }
>>
>>
>>
>>
>> On Wed, Dec 29, 2010 at 2:37 PM, Tim Koop <ti...@timkoop.com> wrote:
>>
>> I have a class I call UserDetails, which is a SessionState object. I use
>>> it like this on a component page:
>>> @SessionState
>>> private UserDetails userDetails;
>>>
>>> However, in my UserDetails class I want to retrieve Cookies like this:
>>> @Inject
>>> private Cookies cookies;
>>>
>>> But I don't think you can inject Tapestry objects on a non-component or
>>> non-page object, can you?
>>>
>>> Any ideas?
>>>
>>> Thanks.
>>>
>>> --
>>> Tim Koop
>>> tim@timkoop.com <ma...@timkoop.com>
>>> www.timkoop.com <http://www.timkoop.com>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> Consultor, desenvolvedor e instrutor em Java, Tapestry e Hibernate
> Coordenador e professor da Especialização em Engenharia de Software com
> Ênfase em Java da Faculdade Pitágoras
> http://www.arsmachina.com.br
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: Inject Cookies into a SessionState object
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
You don't even need the @InjectService or @Inject annotations for
injection to be done in constructors of services.
Naming your session state class Visit makes me 99% sure you were a
Tapestry 4 or 3 user. :P
On Wed, 29 Dec 2010 18:19:12 -0200, Bryan Lewis <jb...@gmail.com>
wrote:
> Here's what's been working for us, constructor injecion. (My syntax
> might be a bit old and deprecated by now?)
>
>
> public Visit(@InjectService("Cookies") Cookies cookieService)
> {
> this.cookieService = cookieService;
> }
>
> // Just to make sure I don't try to do 'new Visit()', hide this
> constructor.
> private Visit()
> {
> }
>
>
>
>
> On Wed, Dec 29, 2010 at 2:37 PM, Tim Koop <ti...@timkoop.com> wrote:
>
>> I have a class I call UserDetails, which is a SessionState object. I
>> use
>> it like this on a component page:
>> @SessionState
>> private UserDetails userDetails;
>>
>> However, in my UserDetails class I want to retrieve Cookies like this:
>> @Inject
>> private Cookies cookies;
>>
>> But I don't think you can inject Tapestry objects on a non-component or
>> non-page object, can you?
>>
>> Any ideas?
>>
>> Thanks.
>>
>> --
>> Tim Koop
>> tim@timkoop.com <ma...@timkoop.com>
>> www.timkoop.com <http://www.timkoop.com>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
Consultor, desenvolvedor e instrutor em Java, Tapestry e Hibernate
Coordenador e professor da Especialização em Engenharia de Software com
Ênfase em Java da Faculdade Pitágoras
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Inject Cookies into a SessionState object
Posted by Bryan Lewis <jb...@gmail.com>.
Here's what's been working for us, constructor injecion. (My syntax might
be a bit old and deprecated by now?)
public Visit(@InjectService("Cookies") Cookies cookieService)
{
this.cookieService = cookieService;
}
// Just to make sure I don't try to do 'new Visit()', hide this
constructor.
private Visit()
{
}
On Wed, Dec 29, 2010 at 2:37 PM, Tim Koop <ti...@timkoop.com> wrote:
> I have a class I call UserDetails, which is a SessionState object. I use
> it like this on a component page:
> @SessionState
> private UserDetails userDetails;
>
> However, in my UserDetails class I want to retrieve Cookies like this:
> @Inject
> private Cookies cookies;
>
> But I don't think you can inject Tapestry objects on a non-component or
> non-page object, can you?
>
> Any ideas?
>
> Thanks.
>
> --
> Tim Koop
> tim@timkoop.com <ma...@timkoop.com>
> www.timkoop.com <http://www.timkoop.com>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>