You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by nicholas Krul <ni...@gmail.com> on 2008/04/12 23:04:22 UTC

RequestGlobals in a PersistentFieldStrategy

Hi guys.

I have implemented a new PersistentFieldStrategy (cookie based), and am
having just one problem...

@Inject
    private RequestGlobals requestGlobals

isn't processed... and I know of no other way to get it into the strategy to
make it work (it is from the base package).

I don't care how, just need access to RequestGlobals... for access to
servlet cookie control (T5 cookies doesn;t have a 'list' ability).

Thanks

--nK

Re: RequestGlobals in a PersistentFieldStrategy

Posted by "Filip S. Adamsen" <fs...@fsadev.com>.
You, good sir, rule.

Thanks for the code. :)

-Filip

On 2008-04-14 21:23, nicholas Krul wrote:
> Hello....
> 
> Rob, I asked for help... I got it. If you cant contribute, don't. I have no
> respect for people who only seek to tear down and not to build.
> 
> And to everyone else....
> 
> http://wiki.apache.org/tapestry/Tapestry5HowToUsePersistentFieldStrategy
> 
> :)
> 
> thanks
> 
> --nK
> 
> 
> On Mon, Apr 14, 2008 at 5:35 PM, Blower, Andy <An...@proquest.co.uk>
> wrote:
> 
>> Our codebase? So, you do use T5 then Rob? Poor you, I sympathise with
>> using technology you dislike.
>>
>> I'm really looking forward to your perfectly designed web framework where
>> you took the trouble to "Think and design before you code" though, avoiding
>> temptations and saving much misery and pain. When are you due to announce
>> it?
>>
>> I've got a great name for you to use, you could call it 'Second Coming'.
>>
>> Yours friendliest,
>>
>> Andy.
>>
>>> -----Original Message-----
>>> From: Rob Smeets [mailto:rb.smeets@gmail.com]
>>> Sent: 14 April 2008 17:10
>>> To: Tapestry users
>>> Subject: Re: RequestGlobals in a PersistentFieldStrategy
>>>> In fact, if I was doing the code again, module classes would not have
>>>> instance methods, only static methods.
>>> Please, please help. Howard, take your hands off that code, ok. You'll
>>> break
>>> our current code base. You may do it in Tapestry 6. Because, again that
>>> would be it's own beast- as usual another 100% backward incompatible
>>> with
>>> previous versions. Tapestry users, BEWARE!!
>>>  A piece of advice to Howard: Think and design before you code. If you
>>> do so
>>> you would avoid all these temptations and save so many people misery
>>> and
>>> pain.
>>>
>>> Yours friendly,
>>>
>>> Rob
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 

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


Re: RequestGlobals in a PersistentFieldStrategy

Posted by nicholas Krul <ni...@gmail.com>.
Hello....

Rob, I asked for help... I got it. If you cant contribute, don't. I have no
respect for people who only seek to tear down and not to build.

And to everyone else....

http://wiki.apache.org/tapestry/Tapestry5HowToUsePersistentFieldStrategy

:)

thanks

--nK


On Mon, Apr 14, 2008 at 5:35 PM, Blower, Andy <An...@proquest.co.uk>
wrote:

> Our codebase? So, you do use T5 then Rob? Poor you, I sympathise with
> using technology you dislike.
>
> I'm really looking forward to your perfectly designed web framework where
> you took the trouble to "Think and design before you code" though, avoiding
> temptations and saving much misery and pain. When are you due to announce
> it?
>
> I've got a great name for you to use, you could call it 'Second Coming'.
>
> Yours friendliest,
>
> Andy.
>
> > -----Original Message-----
> > From: Rob Smeets [mailto:rb.smeets@gmail.com]
> > Sent: 14 April 2008 17:10
> > To: Tapestry users
> > Subject: Re: RequestGlobals in a PersistentFieldStrategy
> > >
> > > In fact, if I was doing the code again, module classes would not have
> > > instance methods, only static methods.
> >
> > Please, please help. Howard, take your hands off that code, ok. You'll
> > break
> > our current code base. You may do it in Tapestry 6. Because, again that
> > would be it's own beast- as usual another 100% backward incompatible
> > with
> > previous versions. Tapestry users, BEWARE!!
> >  A piece of advice to Howard: Think and design before you code. If you
> > do so
> > you would avoid all these temptations and save so many people misery
> > and
> > pain.
> >
> > Yours friendly,
> >
> > Rob
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

RE: RequestGlobals in a PersistentFieldStrategy

Posted by "Blower, Andy" <An...@proquest.co.uk>.
Our codebase? So, you do use T5 then Rob? Poor you, I sympathise with using technology you dislike.

I'm really looking forward to your perfectly designed web framework where you took the trouble to "Think and design before you code" though, avoiding temptations and saving much misery and pain. When are you due to announce it?

I've got a great name for you to use, you could call it 'Second Coming'.

Yours friendliest,

Andy.

> -----Original Message-----
> From: Rob Smeets [mailto:rb.smeets@gmail.com]
> Sent: 14 April 2008 17:10
> To: Tapestry users
> Subject: Re: RequestGlobals in a PersistentFieldStrategy
> >
> > In fact, if I was doing the code again, module classes would not have
> > instance methods, only static methods.
>
> Please, please help. Howard, take your hands off that code, ok. You'll
> break
> our current code base. You may do it in Tapestry 6. Because, again that
> would be it's own beast- as usual another 100% backward incompatible
> with
> previous versions. Tapestry users, BEWARE!!
>  A piece of advice to Howard: Think and design before you code. If you
> do so
> you would avoid all these temptations and save so many people misery
> and
> pain.
>
> Yours friendly,
>
> Rob

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


Re: RequestGlobals in a PersistentFieldStrategy

Posted by Rob Smeets <rb...@gmail.com>.
>
>
> In fact, if I was doing the code again, module classes would not have
> instance methods, only static methods.


Please, please help. Howard, take your hands off that code, ok. You'll break
our current code base. You may do it in Tapestry 6. Because, again that
would be it's own beast- as usual another 100% backward incompatible with
previous versions. Tapestry users, BEWARE!!
 A piece of advice to Howard: Think and design before you code. If you do so
you would avoid all these temptations and save so many people misery and
pain.

Yours friendly,

Rob


>
>
> On Mon, Apr 14, 2008 at 4:39 AM, Tomasz Dziurko <td...@gmail.com>
> wrote:
> > As fas as I know T5 method build() in AppModule is static, so you need
> >  make RequestGlobals static variable:
> >
> >  @Inject
> >  private static RequestGlobals requestGlobals;
> >
> >  to pass it to constructor of mentioned service. When you try to get
> >  something (eg HTTPServletRequesst ) from it after calling service you
> >  will get NullPointerException, so I think it's not the right way.
> >
> >  Regards
> >  --
> >  Tomasz Dziurko
> >
> >
> >
> >  ---------------------------------------------------------------------
> >  To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >  For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
>
> --
> Howard M. Lewis Ship
>
> Creator Apache Tapestry and Apache HiveMind
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: RequestGlobals in a PersistentFieldStrategy

Posted by Howard Lewis Ship <hl...@gmail.com>.
Have to jump in here; sorry Tomasz, wrong on all counts :-)  But
thanks for trying to help out.

Filip is right, for services you don't use @Inject on fields; you gain
access to dependencies via your constructor.  Tapestry doesn't
manipulate your service classes the way it does components, and
@Inject on fields is based on lots of bytecode manipulation.

Also, it doesn't matter at all whether a service is defined in a
module via the bind() method, via a static builder method, or via an
instance builder method.

In fact, if I was doing the code again, module classes would not have
instance methods, only static methods.

On Mon, Apr 14, 2008 at 4:39 AM, Tomasz Dziurko <td...@gmail.com> wrote:
> As fas as I know T5 method build() in AppModule is static, so you need
>  make RequestGlobals static variable:
>
>  @Inject
>  private static RequestGlobals requestGlobals;
>
>  to pass it to constructor of mentioned service. When you try to get
>  something (eg HTTPServletRequesst ) from it after calling service you
>  will get NullPointerException, so I think it's not the right way.
>
>  Regards
>  --
>  Tomasz Dziurko
>
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>  For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

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


Re: RequestGlobals in a PersistentFieldStrategy

Posted by "Filip S. Adamsen" <fs...@fsadev.com>.
What he said!

-Filip

On 2008-04-14 14:32, Peter Stavrinides wrote:
> This actually sounds quite interesting!  share pls.
> 
> 
> nicholas Krul wrote:
>> Filip got it for me
>>
>> the method is contributePersistenceStrategry (or something like that - 
>> from
>> TapestryModule)... just include the RequestGlobals interface (or 
>> Cookies, or
>> whatever) and its taken care of.
>>
>> because its automatically injected into the method signature (no 
>> annotation
>> needed), it doesn't need to be static.
>>
>> So now I have a @Persist("cookie") and an @Persist("flashcookie")... and
>> thanks to @Meta("tapestry.persistence-strategy=flashcookie") no sessions
>> till logged in.
>>
>> If anyone wants, I can share the code. It does have some cookie-data
>> minimalisation logic (not all base64), but thats easily ripped out for
>> production level code (just b64 everything).
>>
>> On Mon, Apr 14, 2008 at 12:39 PM, Tomasz Dziurko <td...@gmail.com> 
>> wrote:
>>
>>  
>>> As fas as I know T5 method build() in AppModule is static, so you need
>>> make RequestGlobals static variable:
>>>
>>> @Inject
>>> private static RequestGlobals requestGlobals;
>>>
>>> to pass it to constructor of mentioned service. When you try to get
>>> something (eg HTTPServletRequesst ) from it after calling service you
>>> will get NullPointerException, so I think it's not the right way.
>>>
>>> Regards
>>> -- 
>>> Tomasz Dziurko
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>     
>>
>>   
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 

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


Re: RequestGlobals in a PersistentFieldStrategy

Posted by Peter Stavrinides <p....@albourne.com>.
This actually sounds quite interesting!  share pls.


nicholas Krul wrote:
> Filip got it for me
>
> the method is contributePersistenceStrategry (or something like that - from
> TapestryModule)... just include the RequestGlobals interface (or Cookies, or
> whatever) and its taken care of.
>
> because its automatically injected into the method signature (no annotation
> needed), it doesn't need to be static.
>
> So now I have a @Persist("cookie") and an @Persist("flashcookie")... and
> thanks to @Meta("tapestry.persistence-strategy=flashcookie") no sessions
> till logged in.
>
> If anyone wants, I can share the code. It does have some cookie-data
> minimalisation logic (not all base64), but thats easily ripped out for
> production level code (just b64 everything).
>
> On Mon, Apr 14, 2008 at 12:39 PM, Tomasz Dziurko <td...@gmail.com> wrote:
>
>   
>> As fas as I know T5 method build() in AppModule is static, so you need
>> make RequestGlobals static variable:
>>
>> @Inject
>> private static RequestGlobals requestGlobals;
>>
>> to pass it to constructor of mentioned service. When you try to get
>> something (eg HTTPServletRequesst ) from it after calling service you
>> will get NullPointerException, so I think it's not the right way.
>>
>> Regards
>> --
>> Tomasz Dziurko
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>     
>
>   

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


Re: RequestGlobals in a PersistentFieldStrategy

Posted by nicholas Krul <ni...@gmail.com>.
Filip got it for me

the method is contributePersistenceStrategry (or something like that - from
TapestryModule)... just include the RequestGlobals interface (or Cookies, or
whatever) and its taken care of.

because its automatically injected into the method signature (no annotation
needed), it doesn't need to be static.

So now I have a @Persist("cookie") and an @Persist("flashcookie")... and
thanks to @Meta("tapestry.persistence-strategy=flashcookie") no sessions
till logged in.

If anyone wants, I can share the code. It does have some cookie-data
minimalisation logic (not all base64), but thats easily ripped out for
production level code (just b64 everything).

On Mon, Apr 14, 2008 at 12:39 PM, Tomasz Dziurko <td...@gmail.com> wrote:

> As fas as I know T5 method build() in AppModule is static, so you need
> make RequestGlobals static variable:
>
> @Inject
> private static RequestGlobals requestGlobals;
>
> to pass it to constructor of mentioned service. When you try to get
> something (eg HTTPServletRequesst ) from it after calling service you
> will get NullPointerException, so I think it's not the right way.
>
> Regards
> --
> Tomasz Dziurko
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: RequestGlobals in a PersistentFieldStrategy

Posted by Tomasz Dziurko <td...@gmail.com>.
As fas as I know T5 method build() in AppModule is static, so you need
make RequestGlobals static variable:

@Inject
private static RequestGlobals requestGlobals;

to pass it to constructor of mentioned service. When you try to get
something (eg HTTPServletRequesst ) from it after calling service you
will get NullPointerException, so I think it's not the right way.

Regards
-- 
Tomasz Dziurko

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


Re: RequestGlobals in a PersistentFieldStrategy

Posted by "Filip S. Adamsen" <fs...@fsadev.com>.
Hi Nicholas,

@Inject doesn't work in services, you'll have to inject RequestGlobals 
through your service's constructor instead:

   public CookiePersistentFieldStrategy(RequestGlobals requestGlobals, 
...) {
     this.requestGlobals = requestGlobals;
     ...
   }

That should work.

-Filip

On 2008-04-12 23:04, nicholas Krul wrote:
> Hi guys.
> 
> I have implemented a new PersistentFieldStrategy (cookie based), and am
> having just one problem...
> 
> @Inject
>     private RequestGlobals requestGlobals
> 
> isn't processed... and I know of no other way to get it into the strategy to
> make it work (it is from the base package).
> 
> I don't care how, just need access to RequestGlobals... for access to
> servlet cookie control (T5 cookies doesn;t have a 'list' ability).
> 
> Thanks
> 
> --nK
> 

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