KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > mvc > controller > form > FormAction


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.verge.mvc.controller.form;
8
9
10 import javax.servlet.http.HttpServletRequest JavaDoc;
11 import javax.servlet.http.HttpServletResponse JavaDoc;
12
13 import com.inversoft.beans.BeanException;
14 import com.inversoft.verge.mvc.controller.Action;
15 import com.inversoft.verge.mvc.controller.form.config.FormConfig;
16 import com.inversoft.verge.util.RequestContext;
17 import com.inversoft.verge.util.WebBean;
18
19
20 /**
21  * <p>
22  * This class contains the objects and information that
23  * might needed by the action handler for a form. The action
24  * handler is called by the Inversoft framework and a new
25  * instance of this class is passed to the handle method.
26  * </p>
27  *
28  * @author Brian Pontarelli
29  * @since 1.0
30  * @version 2.0
31  */

32 public class FormAction extends Action {
33
34     private FormConfig formConfig;
35
36
37     /**
38      * Creates a new form event
39      */

40     public FormAction(FormConfig formConfig, String JavaDoc action,
41             HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response,
42             RequestContext requestContext) {
43         super(action, request, response, requestContext);
44         this.formConfig = formConfig;
45     }
46
47     /**
48      * Creates a new form event
49      */

50     public FormAction(String JavaDoc action, HttpServletRequest JavaDoc request,
51             HttpServletResponse JavaDoc response, RequestContext requestContext) {
52         super(action, request, response, requestContext);
53     }
54
55
56     /**
57      * Gets the {@link com.inversoft.verge.mvc.controller.form.config.FormConfig
58      * FormConfig} object that describes the configuration of the form that was
59      * submitted in order to call the handle method. This method will return
60      * null if the handle method was called from an anchor tag or if the
61      * controller is not the form based MVC
62      */

63     public FormConfig getFormConfig() {
64         return formConfig;
65     }
66
67     /**
68      * A convinence method. The form bean instance is available via the form config
69      * object as well, if a form bean was associated with the form.
70      *
71      * @param name The name of the form bean to retrieve
72      * @return The form bean instance, unless no form bean is associated with the
73      * form in which case this returns null
74      * @throws BeanException If there was a problem instantiating the form bean,
75      * if need be
76      */

77     public Object JavaDoc getFormBean(String JavaDoc name) throws BeanException {
78         WebBean wb = getFormConfig().getFormBean(name);
79         return (wb == null) ? null : wb.getInstance(getHttpServletRequest());
80     }
81 }
Popular Tags