View Javadoc
1   /*
2    * $Id$
3    *
4    * Copyright 1999-2004 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  
20  package org.apache.struts.webapp.exercise;
21  
22  
23  import jakarta.servlet.http.HttpServletRequest;
24  import jakarta.servlet.http.HttpServletResponse;
25  
26  import org.apache.struts.action.Action;
27  import org.apache.struts.action.ActionForm;
28  import org.apache.struts.action.ActionForward;
29  import org.apache.struts.action.ActionMapping;
30  
31  
32  /**
33   * Do-nothing action that accepts the changes made automatically in our form
34   * bean, and then returns control to the input form (if "Save" was pressed)
35   * or the main menu (if "Cancel" was pressed).
36   *
37   * @version $Rev$ $Date$
38   */
39  
40  public class HtmlSettersAction extends Action {
41      private static final long serialVersionUID = 973105280406850142L;
42  
43  
44      /**
45       * Forward to the input form if "Save" was pressed or the main menu
46       * if "Cancel" was pressed.
47       *
48       * @param mapping The ActionMapping used to select this instance
49       * @param form The optional ActionForm bean for this request
50       * @param request The servlet request we are processing
51       * @param response The servlet response we are creating
52       *
53       * @exception Exception if business logic throws an exception
54       */
55      public ActionForward execute(ActionMapping mapping,
56                                   ActionForm form,
57                                   HttpServletRequest request,
58                                   HttpServletResponse response)
59          throws Exception {
60  
61          if (isCancelled(request))
62              return (mapping.findForward("redirect-default"));
63          else
64              return (mapping.findForward("input"));
65  
66      }
67  }