Thanks Joost. This should work too. I will post this solution in the wiki along 
with mine. I didn't write the custom login page that plugs into tapestry 
security yet but this should work 



On Sep 11, 2011, at 1:06 PM, "Joost Schouten (mailing lists)" 
<joost...@jsportal.com> wrote:

> I am not quite sure if this works for you as we have build our own
> security package that protects page and event access and redirects to
> the loginpage when required. On a loginpage forward we store the
> requested page to be redirected to after login. The trick with the
> AJAX call login forward we solve by an onActivate in the login page as
> follows:
> 
> /**
>     * when a user is redirected to the Logon page through a AJAX
> request after their session has expired,
>     * return an json response that redirects them to the logon page
>     * @return
>     * @throws IOException
>     */
>    @OnEvent(value = EventConstants.ACTIVATE)
>    private Object activate() throws IOException {
>        if(request.isXHR()) {
>            PrintWriter writer = response.getPrintWriter("application/json");
>            Link link = linkSource.createPageRenderLink(Login.class);
>            writer.write("{\n\t\"redirectURL\" : \"" +
> link.toAbsoluteURI() + "\"\n}");
>            writer.close();
>        }
>        return null;
>    }
> 
> Hope it helps,
> Joost
> 
> On Sun, Sep 11, 2011 at 4:06 AM, Lenny Primak <lpri...@hope.nyc.ny.us> wrote:
>> I solved this problem finally by making a component somewhat derivative of
>> tapestry-conversations moderator component.
>> Wasn't easy in the last bit.  I will post the code to wiki shortly.
>> What it does is just redirect to the same page if sessions expires,
>> allowing the user to relogin, or if the 'remember me' feature is used,
>> the page just reloads properly.
>> 
>> Thanks everyone for helping me.
>> 
>> On Sep 10, 2011, at 2:42 PM, Lenny Primak wrote:
>> 
>>> That would be great, but I personally would be very happy with just a 
>>> redirect to the current page,
>>> which would just get me a login prompt once again,
>>> but I suppose there are deeper tapestry-related javascript issues going on 
>>> here,
>>> otherwise this problem would have been licked already.
>>> 
>>> On Sep 10, 2011, at 2:37 PM, Fernando Padilla wrote:
>>> 
>>>> Hm..
>>>> 
>>>> Did someone already propose to have Tapestry-Security support a 
>>>> popup-login flow?
>>>> 
>>>> So when tapestry-security hijacks a ajax request, it would return a 
>>>> multizoneupdate that would generate a popup-zone (tapestry doesn't have 
>>>> native support for those yet, but really should!); and would handle the 
>>>> login flow within a popup, and replay the original ajax request after it's 
>>>> done?
>>>> 
>>>> 
>>>> This is a stretch though, since there are a few things needed:
>>>> 
>>>> 1) a zone that support popup or dialog
>>>> 2) security that has a new popup/dialog display option/flow
>>>> 3) a really excited hacker to hack all of this and submit a patch! :)
>>>> 
>>>> 
>>>> On 9/10/11 10:23 AM, Lenny Primak wrote:
>>>>> Did anybody test tapestry-conversation under Tap 5.3 (beta 5?)
>>>>> I am getting ReferenceError: Can't find variable: ConversationModerator
>>>>> The ConversationModerator.js doesn't seem to get included into the 
>>>>> Tapestry page,
>>>>> but the component is there.
>>>>> 
>>>>> On Sep 10, 2011, at 12:29 PM, Lenny Primak wrote:
>>>>> 
>>>>>> Thanks, Kalle,
>>>>>> I think this will work.
>>>>>> I would love, if its possible, for tap-security, perhaps? to be able to 
>>>>>> redirect AJAX requests
>>>>>> correctly to the current page or login page in case the session expired.
>>>>>> That way, it would all work automatically, instead of showing ugly 
>>>>>> exception on the screen.
>>>>>> I will try your method in the meanwhile, the session end warning sounds 
>>>>>> like a good idea.
>>>>>> 
>>>>>> On Sep 10, 2011, at 10:52 AM, Kalle Korhonen wrote:
>>>>>> 
>>>>>>> On Sat, Sep 10, 2011 at 2:39 AM, Lenny Primak<lpri...@hope.nyc.ny.us>  
>>>>>>> wrote:
>>>>>>>> Digging through this a bit deeper, there is an interaction going on 
>>>>>>>> here with tapestry-security.
>>>>>>>> When the session expires, the user is no longer logged in, and thus
>>>>>>>> ajax call is being redirected to a login screen, thus the exceptions.
>>>>>>>> But the problem still remains the same, there seems to be no good way
>>>>>>>> to redirect the page to itself when the Grid does inPlace update,
>>>>>>>> and the session is no longer available.
>>>>>>>> Any more thoughts/ideas?
>>>>>>> Sounds like tapestry-security is doing the right thing, no? How I
>>>>>>> would solve the problem, is that either I wouldn't let the session to
>>>>>>> expire or warn the user that the session is about to expire, or a
>>>>>>> combination of both. If you added conversational scope, it'd be
>>>>>>> relatively easy to do (see
>>>>>>> http://tynamo.org/tapestry-conversations+guide for more info).
>>>>>>> 
>>>>>>> Kalle
>>>>>>> 
>>>>>>> 
>>>>>>>> On Sep 10, 2011, at 4:38 AM, Lenny Primak wrote:
>>>>>>>> 
>>>>>>>>> As a matter of fact, I can't get any sort of graceful degradation 
>>>>>>>>> after session has expired.
>>>>>>>>> 
>>>>>>>>> ----------- Screenshot ------------
>>>>>>>>> <PastedGraphic-1.tiff>
>>>>>>>>> 
>>>>>>>>> // somewhere we trigger session invalidation
>>>>>>>>>       request.getSession(false).invalidate();
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> // now lets try an AJAX event handler to redirect to my index page
>>>>>>>>>   @OnEvent(value = "submit", component = "SearchForm")
>>>>>>>>>   public Object searchCustomer()
>>>>>>>>>   {
>>>>>>>>>           return IndexPage.class;
>>>>>>>>>   }
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> On Sep 10, 2011, at 1:40 AM, Taha Hafeez wrote:
>>>>>>>>> 
>>>>>>>>>> Hi Lenny
>>>>>>>>>> 
>>>>>>>>>> I handle this issue in a more generic way for all ajax calls.
>>>>>>>>>> 
>>>>>>>>>> http://tapestry.1045711.n5.nabble.com/Tapestry-Zone-and-Expired-Session-td4634714.html#a4634757
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> On Sat, Sep 10, 2011 at 10:23 AM, Lenny 
>>>>>>>>>> Primak<lpri...@hope.nyc.ny.us>  wrote:
>>>>>>>>>>> I cannot believe that no one has run into that issue.
>>>>>>>>>>> Seems like anyone that's using the AJAX Grid would face it.
>>>>>>>>>>> 
>>>>>>>>>>> Please vote for https://issues.apache.org/jira/browse/TAP5-1634
>>>>>>>>>>> if you care, or if anyone has a workaround, please suggest one.
>>>>>>>>>>> 
>>>>>>>>>>> Thanks
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> On Sep 2, 2011, at 5:24 PM, Lenny Primak wrote:
>>>>>>>>>>> 
>>>>>>>>>>>> Seems to me that this would be a common thing with any of the AJAX 
>>>>>>>>>>>> components.
>>>>>>>>>>>> Should I open up a JIRA issue?
>>>>>>>>>>>> 
>>>>>>>>>>>> On Fri, 02 Sep 2011 18:14:28 -0300, Lenny 
>>>>>>>>>>>> Primak<lpri...@hope.nyc.ny.us>  wrote:
>>>>>>>>>>>> 
>>>>>>>>>>>>> I figured that was a simple one.  Should not have thought so.
>>>>>>>>>>>>> all my questions are complicated, otherwise I would have not 
>>>>>>>>>>>>> asked :)
>>>>>>>>>>>> hehehe :)
>>>>>>>>>>>> 
>>>>>>>>>>>>> On Sep 2, 2011, at 5:11 PM, Thiago H. de Paula Figueiredo wrote:
>>>>>>>>>>>>> 
>>>>>>>>>>>>>> On Fri, 02 Sep 2011 17:43:42 -0300, Lenny 
>>>>>>>>>>>>>> Primak<lpri...@hope.nyc.ny.us>  wrote:
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> Oh you are here Thiago!
>>>>>>>>>>>>>> I'm always here, but I don't know the answers for all questions 
>>>>>>>>>>>>>> nor the time to investigate them. (I wish I had).
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> How about my Grid/Sessino invalidation session question?
>>>>>>>>>>>>>> I have no idea . . .
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> --
>>>>>>>>>>>>>> Thiago H. de Paula Figueiredo
>>>>>>>>>>>>>> Independent Java, Apache Tapestry 5 and Hibernate consultant, 
>>>>>>>>>>>>>> developer, and instructor
>>>>>>>>>>>>>> Owner, Ars Machina Tecnologia da Informação Ltda.
>>>>>>>>>>>>>> http://www.arsmachina.com.br
>>>>>>>>>>>> On Sep 2, 2011, at 11:10 AM, Lenny Primak wrote:
>>>>>>>>>>>> 
>>>>>>>>>>>>> Hi,
>>>>>>>>>>>>> I've looked all over the Internet for this, but nothing works.
>>>>>>>>>>>>> 
>>>>>>>>>>>>> I have a basic Grid pulling data from an Entity bean.
>>>>>>>>>>>>> Obviously, when session expires, I get the "there is no data to 
>>>>>>>>>>>>> display" message.
>>>>>>>>>>>>> What I really want to do is to redirect to the current page, so 
>>>>>>>>>>>>> the user gets to relogin and session
>>>>>>>>>>>>> gets re-established.
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Here's what I tried:
>>>>>>>>>>>>> 
>>>>>>>>>>>>> @SuppressWarnings("unused")
>>>>>>>>>>>>> @OnEvent(value="inplaceUpdate", component="usersGrid")
>>>>>>>>>>>>> private Object ajaxPageChanged()
>>>>>>>>>>>>> {
>>>>>>>>>>>>>     if(request.getSession(false) != null)
>>>>>>>>>>>>>     {
>>>>>>>>>>>>>         return null;
>>>>>>>>>>>>>     }
>>>>>>>>>>>>>     else
>>>>>>>>>>>>>     {
>>>>>>>>>>>>>       return ps.createPageRenderLink(LoginPage.class).;
>>>>>>>>>>>>>     }
>>>>>>>>>>>>> }
>>>>>>>>>>>>> 
>>>>>>>>>>>>> I get an exception:
>>>>>>>>>>>>> Caused by: java.lang.IllegalArgumentException: Event 
>>>>>>>>>>>>> 'inplaceupdate' from test/TapPage:usersgrid.pager received an 
>>>>>>>>>>>>> event handler method return value of 
>>>>>>>>>>>>> /com.bettaway_baw-website_war_1.2/loginpage. This type of event 
>>>>>>>>>>>>> does not support return values from event handler methods.
>>>>>>>>>>>>>    at 
>>>>>>>>>>>>> org.apache.tapestry5.internal.util.NotificationEventCallback.handleResult(NotificationEventCallback.java:39)
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Thanks for all your help!
>>>>>>>>>>> 
>>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>>>>>>>>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> --
>>>>>>>>>> Regards
>>>>>>>>>> 
>>>>>>>>>> Taha Hafeez Siddiqi (tawus)
>>>>>>>>>> http://tawus.wordpress.com
>>>>>>>>>> 
>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>>>>>>>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>>>>>>>>> 
>>>>>>>> 
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>>>>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>>>>>> 
>>>>>> 
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>>>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>>>>> 
>>>>> 
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>>>> 
>>>> 
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>>> 
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>> 
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
> 

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

Reply via email to