NOTE: This is outdated information that applies only to Tapestry 4.

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 not logout?, 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, your logout method should 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.

LogoutLinkTap4 (last edited 2011-01-02 02:33:27 by BobHarner)