View Javadoc
1   /*
2    * $Id$
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  package examples.validator;
23  
24  import jakarta.servlet.http.HttpServletRequest;
25  import jakarta.servlet.http.HttpServletResponse;
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   * Retrieve and process data from the submitted form
34   *
35   * @version $Rev$ $Date$
36   */
37  public class ProcessValidatorAction extends Action {
38      private static final long serialVersionUID = 4006490239835245976L;
39  
40      // ------------------------------------------------------------ Constructors
41  
42      /**
43       * Constructor for ProcessOptionsAction.
44       */
45      public ProcessValidatorAction() {
46          super();
47      }
48  
49      // ---------------------------------------------------------- Action Methods
50  
51      /**
52       * Process the request and return an <code>ActionForward</code> instance
53       * describing where and how control should be forwarded, or
54       * <code>null</code>if the response has already been completed.
55       *
56       * @param mapping The ActionMapping used to select this instance
57       * @param form The optional ActionForm bean for this request (if any)
58       * @param request The HTTP request we are processing
59       * @param response The HTTP response we are creating
60       *
61       * @exception Exception if the application logic throws an exception
62       *
63       * @return the ActionForward for the next view
64       */
65      public ActionForward execute(
66          ActionMapping mapping,
67          ActionForm form,
68          HttpServletRequest request,
69          HttpServletResponse response)
70          throws Exception {
71  
72          // If user pressed 'Cancel' button,
73          // return to home page
74          if (isCancelled(request)) {
75              return mapping.findForward("home");
76          }
77  
78          // Forward to result page
79          return mapping.findForward("success");
80      }
81  }