You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by P....@albourne.com on 2009/11/11 08:35:35 UTC
Re: Getting ServletContext inside service
Hi Stefan,
It is not clear to me exactly what you are trying to do, perhaps show some code or be more precise. Inside a service you can get hold of ServletContext using ApplicationGlobals, but for most things and for what you are trying to do, use Tapestry's Context service. I don't see how Context can ever be null though, could it be that you need to be using @InjectService rather than @Inject, I too use constructor injection, so I am not certain about the syntax.
regards,
Peter
--
If you are not an intended recipient of this e-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute it. Please visit http://www.albourne.com/email.html for important additional terms relating to this e-mail.
----- Original Message -----
From: "Benny Law" <be...@gmail.com>
To: "Tapestry users" <us...@tapestry.apache.org>
Sent: Saturday, 31 October, 2009 16:45:45 GMT +02:00 Athens, Beirut, Bucharest, Istanbul
Subject: Re: Getting ServletContext inside service
That depends on how your service is managed. I bind my service using the
static binder in AppModule and use constructor arguments to inject what I
need into my service object, and this works for me.
Benny
On Sat, Oct 31, 2009 at 4:47 AM, Stefan <st...@wammel.com> wrote:
> Thanks Benny,
>
> i've tried that too, but it does not work.
> The context is null.
>
> Here's how i do it:
>
> @Inject
> private org.apache.tapestry5.services.Context context;
>
> Should that work?
>
> Stefan
>
>
>
> Am 30.10.2009 um 23:50 schrieb Benny Law:
>
>
> Hi Stefan,
>>
>> Try injecting org.apache.tapestry5.services.Context into your service and
>> use its getInitParameter() method to retrieve your context parameters.
>>
>> Regards,
>>
>> Benny Law
>>
>> On Fri, Oct 30, 2009 at 3:56 PM, Stefan <st...@wammel.com> wrote:
>>
>> Hi,
>>>
>>> is there a way to get access to the ServletContext inside a service bean?
>>>
>>> I like to configure some parameters within the web.xml which i need in
>>> some
>>> services.
>>> How can i retrieve these parameters?
>>> Injecting "ApplicationGlobals" does not work.
>>>
>>> Where is my mistake?
>>>
>>> Thanks in advance.
>>> Stefan
>>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org