Link: http://wiki.apache.org/jakarta-tapestry/LogoutLinkTap4? Highlight = % 28 logout % 29
Simple answer
Use a servicelink to the restartservice in your page(.html ).
<span jwcid="@ServiceLink" service="ognl:@org.apache.tapestry.Tapestry@RESTART_SERVICE">Logout</span>
This will save on writing extra classes if you don't need them, 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 notLogout?, Etc ).
Listener approach (for versions up to beta-12)
Firstly, you will need to define a listener method in your page (or component) class, And a linkfactory getter.
public abstract IEngineService getRestartService();public ILink logout(IRequestCycle cycle){ // do your own cleanup here return getRestartService.getLink(cycle, false, null);}
Then, in your. Page (or. JWC), inject the linkfactory:
<inject object="engine-service:restart" property="restartService" />
Thirdly Add the listener to your link:
<span jwcid="@DirectLink" listener="listener:logout">Logout</span>
Listener approach (for Versions later than beta-12)
Due to changes to the getlink parameters that occured in beta-13, yourLogoutMethod shoshould now be:
public ILink logout(){ // do your own cleanup here return getRestartService.getLink(false, null);}
Note that since we don't need the irequestcycle in order to generate the ilink, we don't need to include it in our listener either.