KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > webapp > validator > EditTypeAction


1 /*
2  * $Id: EditTypeAction.java 54929 2004-10-16 16:38:42Z germuska $
3  *
4  * Copyright 2000-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 package org.apache.struts.webapp.validator;
20
21 import javax.servlet.http.HttpServletRequest JavaDoc;
22 import javax.servlet.http.HttpServletResponse JavaDoc;
23
24 import java.util.ArrayList JavaDoc;
25 import org.apache.commons.logging.Log;
26 import org.apache.commons.logging.LogFactory;
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 import org.apache.struts.util.LabelValueBean;
32
33 /**
34  * Initializes ActionForm.
35  *
36  */

37 public final class EditTypeAction extends Action {
38
39     /**
40      * Commons Logging instance.
41      */

42     private Log log = LogFactory.getFactory().getInstance(this.getClass().getName());
43
44     /**
45      * Process the specified HTTP request, and create the corresponding HTTP
46      * response (or forward to another web component that will create it).
47      * Return an <code>ActionForward</code> instance describing where and how
48      * control should be forwarded, or <code>null</code> if the response has
49      * already been completed.
50      *
51      * @param mapping The ActionMapping used to select this instance
52      * @param form The optional ActionForm bean for this request (if any)
53      * @param request The HTTP request we are processing
54      * @param response The HTTP response we are creating
55      *
56      * @return Action to forward to
57      * @exception Exception if an input/output error or servlet exception occurs
58      */

59     public ActionForward execute(
60             ActionMapping mapping,
61             ActionForm form,
62             HttpServletRequest JavaDoc request,
63             HttpServletResponse JavaDoc response)
64             throws Exception JavaDoc {
65
66         // Was this transaction cancelled?
67

68         initFormBeans(mapping, form, request);
69
70         return mapping.findForward("success");
71     }
72
73     /**
74      * Convenience method for initializing form bean.
75      * @param mapping The ActionMapping used to select this instance
76      * @param request The HTTP request we are processing
77      */

78     protected void initFormBeans(
79             ActionMapping mapping, ActionForm form,
80             HttpServletRequest JavaDoc request) {
81
82         // Initialize
83
ArrayList JavaDoc satisfactionList = new ArrayList JavaDoc();
84         satisfactionList.add(new LabelValueBean("Very Satisfied", "4"));
85         satisfactionList.add(new LabelValueBean("Satisfied", "3"));
86         satisfactionList.add(new LabelValueBean("Not Very Satisfied", "2"));
87         satisfactionList.add(new LabelValueBean("Not Satisfied", "1"));
88         request.setAttribute("satisfactionList", satisfactionList);
89
90         ArrayList JavaDoc osTypes = new ArrayList JavaDoc();
91         osTypes.add(new LabelValueBean("Mac OsX", "OsX"));
92         osTypes.add(new LabelValueBean("Windows 95/98/Me", "Win32"));
93         osTypes.add(new LabelValueBean("Windows NT/2000/XP/2003", "WinNT"));
94         osTypes.add(new LabelValueBean("Linux", "Linux"));
95         osTypes.add(new LabelValueBean("BSD NetBSD/FreeBSD/OpenBSD", "BSD"));
96         request.setAttribute("osTypes", osTypes);
97
98         ArrayList JavaDoc languageTypes = new ArrayList JavaDoc();
99         languageTypes.add(new LabelValueBean("C++", "C++"));
100         languageTypes.add(new LabelValueBean("C#", "C#"));
101         languageTypes.add(new LabelValueBean("Java", "java"));
102         languageTypes.add(new LabelValueBean("Smalltalk", "Smalltalk"));
103         request.setAttribute("languageTypes", languageTypes);
104     }
105 }
106
Popular Tags