KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > blandware > atleap > webapp > form > contact > ContactForm


1 /*
2  * Copyright 2004 Blandware (http://www.blandware.com)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package com.blandware.atleap.webapp.form.contact;
17
18 import com.blandware.atleap.webapp.form.BaseForm;
19 import org.apache.struts.action.ActionErrors;
20 import org.apache.struts.action.ActionMapping;
21
22 import javax.servlet.http.HttpServletRequest JavaDoc;
23
24 /**
25  * <p>ActionForm bean containing information to send "contact us" mail message</p>
26  * <p><a HREF="ContactForm.java.htm"><i>View Source</i></a></p>
27  *
28  * @author Sergey Zubtcovskii <a HREF="mailto:sergey.zubtcovskii@blandware.com">&lt;sergey.zubtcovskii@blandware.com&gt;</a>
29  * @version $Revision: 1.4 $ $Date: 2005/08/04 17:25:15 $
30  * @struts.form name="contactForm"
31  */

32 public class ContactForm extends BaseForm {
33
34     protected String JavaDoc userName;
35     protected String JavaDoc email;
36     protected String JavaDoc message;
37     protected String JavaDoc preview;
38
39     /**
40      * Creates the new instance of ContactForm
41      */

42     public ContactForm() {
43     }
44
45     /**
46      * Returns name of user who sends this message
47      *
48      * @return Name of user
49      */

50     public String JavaDoc getUserName() {
51         return userName;
52     }
53
54     /**
55      * Sets name of user who sends this message
56      *
57      * @param userName Name of user to set
58      * @struts.validator type="required"
59      * @struts.validator-args arg0resource="contact.form.userName"
60      */

61     public void setUserName(String JavaDoc userName) {
62         this.userName = userName;
63     }
64
65     /**
66      * Gets e-mail address of user who sends message to us
67      *
68      * @return E-mail of user
69      */

70     public String JavaDoc getEmail() {
71         return email;
72     }
73
74     /**
75      * Sets e-mail address of user, who sends message to us
76      *
77      * @param email E-mail of user to set
78      * @struts.validator type="required"
79      * @struts.validator type="email"
80      * @struts.validator-args arg0resource="contact.form.email"
81      */

82     public void setEmail(String JavaDoc email) {
83         this.email = email;
84     }
85
86     /**
87      * Gets message to send
88      *
89      * @return Message to send
90      */

91     public String JavaDoc getMessage() {
92         return message;
93     }
94
95     /**
96      * Sets message to send
97      *
98      * @param message Message to send
99      * @struts.validator type="required"
100      * @struts.validator-args arg0resource="contact.form.message"
101      */

102     public void setMessage(String JavaDoc message) {
103         this.message = message;
104     }
105
106     /**
107      * Returns non-null value if 'preview' button has been pressed
108      *
109      * @return non-null value if user wants to preview message to be sent
110      */

111     public String JavaDoc getPreview() {
112         return preview;
113     }
114
115     /**
116      * Sets value of preview field
117      *
118      * @param preview Value to set
119      */

120     public void setPreview(String JavaDoc preview) {
121         this.preview = preview;
122     }
123
124     /**
125      * Resets all properties to their default values
126      *
127      * @param mapping The ActionMapping used to select this instance
128      * @param request The non-http request we are proceeding
129      */

130     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
131         userName = null;
132         email = null;
133         message = null;
134         preview = null;
135     }
136
137     /**
138      * Form validation
139      *
140      * @param mapping The ActionMapping used to select this instance
141      * @param request The non-http request we are proceeding
142      * @return Instance of ActionErrors contains all validation errors
143      */

144     public ActionErrors validate(ActionMapping mapping, HttpServletRequest JavaDoc request) {
145         ActionErrors errors = new ActionErrors();
146         return errors;
147     }
148 }
Popular Tags