You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Apache Wiki <wi...@apache.org> on 2005/11/16 14:24:55 UTC

[Jakarta-tapestry Wiki] Update of "LogoutLinkTap4" by AndreasAndreou

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Jakarta-tapestry Wiki" for change notification.

The following page has been changed by AndreasAndreou:
http://wiki.apache.org/jakarta-tapestry/LogoutLinkTap4

The comment on the change is:
Update code for beta-13

------------------------------------------------------------------------------
  
  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 =
+ = 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 LinkFactory getLinkFactory();
+ public abstract IEngineService getRestartService();
  
- public void logout(IRequestCycle cycle)
+ public ILink logout(IRequestCycle cycle)
  {
      // do your own cleanup here
  
+     return getRestartService.getLink(cycle, false, null);
-     Map params = new HashMap();
-     params.put(ServiceConstants.SERVICE, Tapestry.RESTART_SERVICE);
-     ILink link = getLinkFactory().constructLink(cycle, false, params, true);
-     String restartUrl = link.getAbsoluteURL();    	
-     throw new RedirectException(restartUrl);
  }
  }}}
  
  Then, in your .page (or .jwc), inject the LinkFactory :
  {{{
-     <inject object="infrastructure:linkFactory" property="linkFactory"></inject>
+     <inject object="engine-service:restart" property="restartService" />
  }}}
  
  Thirdly add the listener to your link:
@@ -37, +33 @@

     <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);
+ }
+ }}}
+ 

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