001: /*
002: * $Id: EditTypeAction.java 471754 2006-11-06 14:55:09Z husted $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021:
022: package org.apache.struts.webapp.validator;
023:
024: import javax.servlet.http.HttpServletRequest;
025: import javax.servlet.http.HttpServletResponse;
026:
027: import java.util.ArrayList;
028: import org.apache.commons.logging.Log;
029: import org.apache.commons.logging.LogFactory;
030: import org.apache.struts.action.Action;
031: import org.apache.struts.action.ActionForm;
032: import org.apache.struts.action.ActionForward;
033: import org.apache.struts.action.ActionMapping;
034: import org.apache.struts.util.LabelValueBean;
035:
036: /**
037: * Initializes ActionForm.
038: *
039: */
040: public final class EditTypeAction extends Action {
041:
042: /**
043: * Commons Logging instance.
044: */
045: private Log log = LogFactory.getFactory().getInstance(
046: this .getClass().getName());
047:
048: /**
049: * Process the specified HTTP request, and create the corresponding HTTP
050: * response (or forward to another web component that will create it).
051: * Return an <code>ActionForward</code> instance describing where and how
052: * control should be forwarded, or <code>null</code> if the response has
053: * already been completed.
054: *
055: * @param mapping The ActionMapping used to select this instance
056: * @param form The optional ActionForm bean for this request (if any)
057: * @param request The HTTP request we are processing
058: * @param response The HTTP response we are creating
059: *
060: * @return Action to forward to
061: * @exception Exception if an input/output error or servlet exception occurs
062: */
063: public ActionForward execute(ActionMapping mapping,
064: ActionForm form, HttpServletRequest request,
065: HttpServletResponse response) throws Exception {
066:
067: // Was this transaction cancelled?
068:
069: initFormBeans(mapping, form, request);
070:
071: return mapping.findForward("success");
072: }
073:
074: /**
075: * Convenience method for initializing form bean.
076: * @param mapping The ActionMapping used to select this instance
077: * @param request The HTTP request we are processing
078: */
079: protected void initFormBeans(ActionMapping mapping,
080: ActionForm form, HttpServletRequest request) {
081:
082: log.debug("initFromBeans");
083:
084: // Initialize
085: ArrayList satisfactionList = new ArrayList();
086: satisfactionList.add(new LabelValueBean("Very Satisfied", "4"));
087: satisfactionList.add(new LabelValueBean("Satisfied", "3"));
088: satisfactionList.add(new LabelValueBean("Not Very Satisfied",
089: "2"));
090: satisfactionList.add(new LabelValueBean("Not Satisfied", "1"));
091: request.setAttribute("satisfactionList", satisfactionList);
092:
093: ArrayList osTypes = new ArrayList();
094: osTypes.add(new LabelValueBean("Mac OsX", "OsX"));
095: osTypes.add(new LabelValueBean("Windows 95/98/Me", "Win32"));
096: osTypes.add(new LabelValueBean("Windows NT/2000/XP/2003",
097: "WinNT"));
098: osTypes.add(new LabelValueBean("Linux", "Linux"));
099: osTypes.add(new LabelValueBean("BSD NetBSD/FreeBSD/OpenBSD",
100: "BSD"));
101: request.setAttribute("osTypes", osTypes);
102:
103: ArrayList languageTypes = new ArrayList();
104: languageTypes.add(new LabelValueBean("C++", "C++"));
105: languageTypes.add(new LabelValueBean("C#", "C#"));
106: languageTypes.add(new LabelValueBean("Java", "java"));
107: languageTypes.add(new LabelValueBean("Smalltalk", "Smalltalk"));
108: request.setAttribute("languageTypes", languageTypes);
109: }
110: }
|