Logout in tapesty4.0

Source: Internet
Author: User
Tags servicelink
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.