tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tapestry-...@jakarta.apache.org
Subject [Jakarta Tapestry Wiki] New: FrequentlyAskedQuestions/LogoutLink
Date Tue, 08 Jun 2004 14:11:25 GMT
   Date: 2004-06-08T07:11:25
   Editor: <>
   Wiki: Jakarta Tapestry Wiki
   Page: FrequentlyAskedQuestions/LogoutLink
   URL: http://wiki.apache.org/jakarta-tapestry/FrequentlyAskedQuestions/LogoutLink

   no comment

New Page:

This is an FAQ on tapestry-users also, so I will base the answer on the response given by
Brian Lewis' GMane posting:

Firstly, you will need to define a listener method in your page class.
''For newbies:''
    1. Subclass org.apache.tapestry.html.BasePage
    1. Add listener method public void logout(IRequestCycle cycle) 
    You can use any method name, just keep the signature the same. IRequestCycle is org.apache.tapestry.IRequestCycle
    1. Change page definition (.page) so that your page-specification has class set to your
new class. 

Inside the listener method, 
public void logout(IRequestCycle cycle)
    IEngine engine = getEngine();

If you look at the source for AbstractEngine, you will see that it invalidates the HttpSession
and redirects the user to the default URL of the servlet. I personally would put any extra
logic required here as it keeps it all in one place.

Thirdly add the listener to your link:
   <span jwcid="@ActionLink" listener="ognl:listeners.logout">Logout</span>
Another (even simpler) approache is to use a ServiceLink to the RestartService.
    <span jwcid="@ServiceLink" service="ognl:@org.apache.tapestry.Tapestry@RESTART_SERVICE">Logout</span>

This will save on the extra class if you don't need it, but stops you from doing other things
in your listener without wrapping the Restart Service (like logging a message, giving the
user the option to not logout?, etc).

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

View raw message