View Javadoc

1   /* ==============================================================================
2    *   JDBCAdmin, data management software.
3    *   Copyright (C) 2005  Norsys S.A
4    *
5    *   This library is free software; you can redistribute it and/or
6    *   modify it under the terms of the GNU Lesser General Public
7    *   License as published by the Free Software Foundation; either
8    *   version 2.1 of the License, or (at your option) any later version.
9    *
10   *   This library is distributed in the hope that it will be useful,
11   *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   *   Lesser General Public License for more details.
14   *
15   *   You should have received a copy of the GNU Lesser General Public
16   *   License along with this library; if not, write to the Free Software
17   *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   * ==============================================================================
19   */
20  package jdbcadmin.web.actions;
21  
22  import javax.servlet.http.HttpServletRequest;
23  import javax.servlet.http.HttpServletResponse;
24  
25  import jdbcadmin.web.ContexteManager;
26  
27  import org.apache.struts.action.Action;
28  import org.apache.struts.action.ActionForm;
29  import org.apache.struts.action.ActionForward;
30  import org.apache.struts.action.ActionMapping;
31  
32  /***
33   * Base class for all actions that need that the user passed by the index.
34   * @author Thomas Recloux (trecloux@norsys.fr)
35   */
36  public abstract class IndexedAction extends Action {
37  
38      /***
39       *  {@inheritDoc}
40       */
41      public final ActionForward execute(ActionMapping mapping, ActionForm form,
42              HttpServletRequest request, HttpServletResponse response) throws Exception {
43  
44          // test if the session has been initialized
45          if (ContexteManager.isInitialized(request)) {
46              return indexedExec(mapping, form, request, response);
47          } else {
48              return mapping.findForward("index");
49          }
50      }
51  
52      /***
53       * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping,
54       * org.apache.struts.action.ActionForm,
55       * javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
56       */
57      public abstract ActionForward indexedExec(ActionMapping mapping, ActionForm form,
58                  HttpServletRequest request, HttpServletResponse response) throws Exception;
59  
60  }