001    package com.sptci.echo2;
002    
003    import nextapp.echo2.app.Button;
004    import nextapp.echo2.app.event.ActionEvent;
005    
006    /**
007     * A generic component that is used to log a user out of an Echo2 session.
008     * Sub-classes that need special handling before invalidating the session
009     * can do so by sub-classing this component and over-riding {@link
010     * #getActionListener} method.
011     *
012     * <p>Copyright 2007 Sans Pareil Technologies, Inc.</p>
013     * @see LogoutListener
014     * @see com.sptci.echo2.http.LogoutServlet
015     * @author Rakesh Vidyadharan 2007-04-23
016     * @version $Id: Logout.java 3271 2007-05-15 02:07:06Z rakesh $
017     */
018    public class Logout extends Button
019    {
020      /**
021       * Create a new instance of the component.  Sets the style name for
022       * this component to the fully qualified class name and adds the
023       * action listener to it.
024       *
025       * @see #getActionListener
026       */
027      public Logout()
028      {
029        super();
030        setStyleName( getClass().getName() );
031        addActionListener( getActionListener() );
032      }
033    
034      /**
035       * Return the action listener to bind to this component.  Sub-classes
036       * should over-ride this method if they wish to extend the default
037       * listener.
038       *
039       * @return The action listener for this component.
040       */
041      protected LogoutListener getActionListener()
042      {
043        return new LogoutListener();
044      }
045    
046      /**
047       * The action listener for this component.
048       */
049      public static class LogoutListener extends RedirectListener
050      {
051        /**
052         * The URL to redirect the client browser to after logging out of
053         * the Echo2 application session.
054         *
055         * {@value}
056         */
057        public static final String URL = "logout";
058    
059        /**
060         * Create a new instance of the action listener.
061         */
062        public LogoutListener()
063        {
064          super( URL );
065        }
066    
067        /**
068         * Create a new instance of the action listener to redirect to the
069         * specified <code>URL</code>.
070         *
071         * @param url The url to redirect to.
072         */
073        public LogoutListener( String url )
074        {
075          super( url );
076        }
077      }
078    }