In T4, you'd have something like the following to grab a global Cayenne
DataContext:
public void setDataContext(final ApplicationStateManager asm)
{
this.dc = (DataContext) asm.get("global-data-context");
}
Exposing the name of the ASO and having to do a cast is not nice. I'll have
to check out the T5 IoC config to see how things might be better there. The
snippet you posted seems to address the problems.
--
Kevin
On 9/12/07 4:53 PM, in article
[EMAIL PROTECTED], "Robert Zeigler"
<[EMAIL PROTECTED]> wrote:
> Hm... it would certainly be nice if a service could have an ASO
> injected into it directly, but that would then mandate a particular
> scope to your service.
> I personally like the approach of injecting the ASM into the service
> and grabbing your ASO's from there. Not familiar with the T4
> ApplicationStateManager service, but the T5 version hasn't been
> painful to use at all:
>
> User u = asm.get(User.class);
> u....
>
> It'll create your ASO's for you, too, if they don't exist yet (you
> can also check to see if they exist if you want to avoid creating them).
>
> Anyway, that's definitely the right way for Cesar to go.
>
> Robert
>
> On Sep 12, 2007, at 9/121:23 PM , Kevin Menard wrote:
>
>> Hmm . . . I haven't really gotten my feet wet with T5 yet. Does
>> this mean
>> that it will still only inject into page classes, as is the case
>> with T4? I
>> was hoping with the move to POJOs that you could inject into arbitrary
>> classes, such as services. The ASM is a pain to use.
>>
>> --
>> Kevin
>>
>>
>> On 9/12/07 2:09 PM, in article [EMAIL PROTECTED], "Filip S.
>> Adamsen" <[EMAIL PROTECTED]> wrote:
>>
>>> Have a look at the ApplicationStateManager service:
>>> http://tapestry.apache.org/tapestry5/tapestry-core/apidocs/org/
>>> apache/tapestry
>>> /services/ApplicationStateManager.html
>>>
>>> -Filip
>>>
>>> César Lesc skrev:
>>>> I need to use data stored in an ASO (user information) to process
>>>> the a
>>>> requests in a service object, i guess the service object must be in
>>>> perthread scope, because the ASO stores his data in the session,
>>>> but the
>>>> @ApplicationState annotation is not working inside the service.
>>>> Finally i
>>>> found the RequestGlobals Service to store and retrieve data in
>>>> the session
>>>> inside a service, but i feel that should be a better approach.
>>>> May be i'm
>>>> missing something.
>>>>
>>>> Thanks in advance
>>>>
>>>> César.
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]