link:http://wiki.apache.org/jakarta-tapestry/LogoutLinkTap4?highlight=%28logout%29

Simple Answer

Use a ServiceLink to the RestartService in your page(.html).

    <span jwc>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 jwc>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.

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-25
  • 2021-06-11
  • 2021-12-18
  • 2021-12-18
  • 2021-05-18
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-05
  • 2021-11-24
  • 2021-11-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案