You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Michael Gentry <mg...@masslight.net> on 2009/09/17 23:08:01 UTC

T5.1 Graceful Session Timeout?

Is there a way in T5.1 to have graceful session timeout handling on
form submission or links?

For example, I have a form with a bunch of inputs and I wait to click
the button until my 2-minute session times out (I'm
developing/debugging, so a short session expiration).  When I submit
the form, I get NPEs because the objects I required (and used @Persist
on) are no longer there.  I'd like a way to gracefully handle that and
present a message or something.  I've been searching the list, the
documentation, the wiki, and the JumpStart, but still haven't found
the right magic.

Thanks,

mrg

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


Re: T5.1 Graceful Session Timeout?

Posted by Peter Stavrinides <P....@albourne.com>.
Hi Michael,

> Is there a way in T5.1 to have graceful session timeout handling on
> form submission or links?
I think a superclass can be an elegant solution... my solution though was to use a dispatcher, my use case was not specific to a form or a few links or a few pages, but rather application wide. I store a callback, redirect back to the login page, then restore the state of the page via the callback.

Cheers,
Peter 


----- Original Message -----
From: "Michael Gentry" <mg...@masslight.net>
To: "Tapestry users" <us...@tapestry.apache.org>
Sent: Friday, 18 September, 2009 23:37:13 GMT +02:00 Athens, Beirut, Bucharest, Istanbul
Subject: Re: T5.1 Graceful Session Timeout?

Since I'm sticking this in a superclass to be inherited by many pages,
I'll pretend it is slightly more efficient to return the .class (which
may not be true at all).

It is indeed less code.  :-)

Thanks Thiago!

mrg


On Fri, Sep 18, 2009 at 4:32 PM, Thiago H. de Paula Figueiredo
<th...@gmail.com> wrote:
> Em Fri, 18 Sep 2009 17:28:03 -0300, Michael Gentry <mg...@masslight.net>
> escreveu:
>
>> Initially I was thinking I might need to set some values in my
>> SessionTimeout page, but now I'm not sure if I'll do that.  I'm
>> assuming returning SessionTimeout.class will be more efficient than
>> injecting the page?
>
> I don't know about performance, but returning SessionTimeout.class doesn't
> need a private field annotated with @InjectPage. A little bit less code. :)
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java consultant, developer, and instructor
> http://www.arsmachina.com.br/thiago
>
> ---------------------------------------------------------------------
> 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: T5.1 Graceful Session Timeout?

Posted by Michael Gentry <mg...@masslight.net>.
Since I'm sticking this in a superclass to be inherited by many pages,
I'll pretend it is slightly more efficient to return the .class (which
may not be true at all).

It is indeed less code.  :-)

Thanks Thiago!

mrg


On Fri, Sep 18, 2009 at 4:32 PM, Thiago H. de Paula Figueiredo
<th...@gmail.com> wrote:
> Em Fri, 18 Sep 2009 17:28:03 -0300, Michael Gentry <mg...@masslight.net>
> escreveu:
>
>> Initially I was thinking I might need to set some values in my
>> SessionTimeout page, but now I'm not sure if I'll do that.  I'm
>> assuming returning SessionTimeout.class will be more efficient than
>> injecting the page?
>
> I don't know about performance, but returning SessionTimeout.class doesn't
> need a private field annotated with @InjectPage. A little bit less code. :)
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java consultant, developer, and instructor
> http://www.arsmachina.com.br/thiago
>
> ---------------------------------------------------------------------
> 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: T5.1 Graceful Session Timeout?

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Fri, 18 Sep 2009 17:28:03 -0300, Michael Gentry <mg...@masslight.net>  
escreveu:

> Initially I was thinking I might need to set some values in my
> SessionTimeout page, but now I'm not sure if I'll do that.  I'm
> assuming returning SessionTimeout.class will be more efficient than
> injecting the page?

I don't know about performance, but returning SessionTimeout.class doesn't  
need a private field annotated with @InjectPage. A little bit less code. :)

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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


Re: T5.1 Graceful Session Timeout?

Posted by Michael Gentry <mg...@masslight.net>.
Initially I was thinking I might need to set some values in my
SessionTimeout page, but now I'm not sure if I'll do that.  I'm
assuming returning SessionTimeout.class will be more efficient than
injecting the page?

Thanks Thiago,

mrg


On Fri, Sep 18, 2009 at 3:33 PM, Thiago H. de Paula Figueiredo
<th...@gmail.com> wrote:
> Em Fri, 18 Sep 2009 16:28:00 -0300, Michael Gentry <mg...@masslight.net>
> escreveu:
>
>>    public Object onPrepareForSubmit()
>>    {
>>        // If there is no session, return the timeout page.
>>        if (sessionExists == false)
>>            return sessionTimeout;
>
> If you don't need to invoke methods in sessionTimeout, you can just return
> SessionTimeout.class with the same result.
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java consultant, developer, and instructor
> http://www.arsmachina.com.br/thiago
>
> ---------------------------------------------------------------------
> 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: T5.1 Graceful Session Timeout?

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Fri, 18 Sep 2009 16:28:00 -0300, Michael Gentry <mg...@masslight.net>  
escreveu:

>     public Object onPrepareForSubmit()
>     {
>         // If there is no session, return the timeout page.
>         if (sessionExists == false)
>             return sessionTimeout;

If you don't need to invoke methods in sessionTimeout, you can just return  
SessionTimeout.class with the same result.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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


Re: T5.1 Graceful Session Timeout?

Posted by Michael Gentry <mg...@masslight.net>.
For any who might need/want this, here is my current solution (this
only works on FORM submits, but can be expanded upon):

    public Object onPrepareForSubmit()
    {
        // If there is no session, return the timeout page.
        if (sessionExists == false)
            return sessionTimeout;
        else
            return null;
    }

    @SessionState
    private Session session;

    private boolean sessionExists;

    @InjectPage
    private SessionTimeout sessionTimeout;

Basically, if the session has vanished, it interrupts the FORM
submission and redirects to the SessionTimeout page.

mrg


On Fri, Sep 18, 2009 at 9:37 AM, Michael Gentry <mg...@masslight.net> wrote:
> Well, I can't just create a new object, since I was editing an
> existing one.  So I had my object persisted, but now it is gone and
> I'm getting an NPE.  Tapestry doesn't seem to know my application
> requires the session (and present a session timeout page) and I
> haven't found a way to tell it to stop processing the FORM submission
> yet.
>
> I'll look at your conversations link and see if that gives me ideas.
>
> mrg
>
>
> On Thu, Sep 17, 2009 at 5:33 PM, Kalle Korhonen
> <ka...@gmail.com> wrote:
>> Just to prevent nullpointers, in your onActivate() you should have if
>> (object == null) object = new Object(). Obviously that could lead to
>> unexpected results to the user - based on object state you could
>> present a a message to the user etc. but there are quite a few
>> different cases that you need to handle. Or you can detach the "page
>> timeout" from session timeout and use some type of conversations, e.g.
>> http://docs.codehaus.org/display/TRAILS/Conversations+in+Trails.
>>
>> Kalle
>>
>>
>> On Thu, Sep 17, 2009 at 2:08 PM, Michael Gentry <mg...@masslight.net> wrote:
>>> Is there a way in T5.1 to have graceful session timeout handling on
>>> form submission or links?
>>>
>>> For example, I have a form with a bunch of inputs and I wait to click
>>> the button until my 2-minute session times out (I'm
>>> developing/debugging, so a short session expiration).  When I submit
>>> the form, I get NPEs because the objects I required (and used @Persist
>>> on) are no longer there.  I'd like a way to gracefully handle that and
>>> present a message or something.  I've been searching the list, the
>>> documentation, the wiki, and the JumpStart, but still haven't found
>>> the right magic.
>>>
>>> Thanks,
>>>
>>> mrg
>>>
>>> ---------------------------------------------------------------------
>>> 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: T5.1 Graceful Session Timeout?

Posted by Michael Gentry <mg...@masslight.net>.
Well, I can't just create a new object, since I was editing an
existing one.  So I had my object persisted, but now it is gone and
I'm getting an NPE.  Tapestry doesn't seem to know my application
requires the session (and present a session timeout page) and I
haven't found a way to tell it to stop processing the FORM submission
yet.

I'll look at your conversations link and see if that gives me ideas.

mrg


On Thu, Sep 17, 2009 at 5:33 PM, Kalle Korhonen
<ka...@gmail.com> wrote:
> Just to prevent nullpointers, in your onActivate() you should have if
> (object == null) object = new Object(). Obviously that could lead to
> unexpected results to the user - based on object state you could
> present a a message to the user etc. but there are quite a few
> different cases that you need to handle. Or you can detach the "page
> timeout" from session timeout and use some type of conversations, e.g.
> http://docs.codehaus.org/display/TRAILS/Conversations+in+Trails.
>
> Kalle
>
>
> On Thu, Sep 17, 2009 at 2:08 PM, Michael Gentry <mg...@masslight.net> wrote:
>> Is there a way in T5.1 to have graceful session timeout handling on
>> form submission or links?
>>
>> For example, I have a form with a bunch of inputs and I wait to click
>> the button until my 2-minute session times out (I'm
>> developing/debugging, so a short session expiration).  When I submit
>> the form, I get NPEs because the objects I required (and used @Persist
>> on) are no longer there.  I'd like a way to gracefully handle that and
>> present a message or something.  I've been searching the list, the
>> documentation, the wiki, and the JumpStart, but still haven't found
>> the right magic.
>>
>> Thanks,
>>
>> mrg
>>
>> ---------------------------------------------------------------------
>> 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: T5.1 Graceful Session Timeout?

Posted by Kalle Korhonen <ka...@gmail.com>.
Just to prevent nullpointers, in your onActivate() you should have if
(object == null) object = new Object(). Obviously that could lead to
unexpected results to the user - based on object state you could
present a a message to the user etc. but there are quite a few
different cases that you need to handle. Or you can detach the "page
timeout" from session timeout and use some type of conversations, e.g.
http://docs.codehaus.org/display/TRAILS/Conversations+in+Trails.

Kalle


On Thu, Sep 17, 2009 at 2:08 PM, Michael Gentry <mg...@masslight.net> wrote:
> Is there a way in T5.1 to have graceful session timeout handling on
> form submission or links?
>
> For example, I have a form with a bunch of inputs and I wait to click
> the button until my 2-minute session times out (I'm
> developing/debugging, so a short session expiration).  When I submit
> the form, I get NPEs because the objects I required (and used @Persist
> on) are no longer there.  I'd like a way to gracefully handle that and
> present a message or something.  I've been searching the list, the
> documentation, the wiki, and the JumpStart, but still haven't found
> the right magic.
>
> Thanks,
>
> mrg
>
> ---------------------------------------------------------------------
> 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