KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > formbean > PaintingForm


1 package formbean;
2
3 import java.math.BigDecimal JavaDoc;
4
5 import javax.servlet.http.HttpServletRequest JavaDoc;
6
7 import org.apache.struts.action.ActionError;
8 import org.apache.struts.action.ActionErrors;
9 import org.apache.struts.action.ActionForm;
10 import org.apache.struts.action.ActionMapping;
11
12 public final class PaintingForm extends ActionForm {
13     
14     private String JavaDoc paintingTitle = null;
15     private BigDecimal JavaDoc estimatedPrice = null;
16     private String JavaDoc artistName = null;
17     
18     public void setEstimatedPrice(BigDecimal JavaDoc value) {
19         estimatedPrice = value;
20     }
21     public BigDecimal JavaDoc getEstimatedPrice() {
22         return estimatedPrice;
23     }
24         
25     public void setPaintingTitle(String JavaDoc value) {
26         paintingTitle = value;
27     }
28     public String JavaDoc getPaintingTitle() {
29         return paintingTitle;
30     }
31     
32     public void setArtistName(String JavaDoc value) {
33         artistName = value;
34     }
35     public String JavaDoc getArtistName() {
36         return artistName;
37     }
38     
39        /**
40      * Reset all properties to their default values.
41      *
42      * @param mapping The mapping used to select this instance
43      * @param request The servlet request we are processing
44      */

45     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
46
47         this.estimatedPrice = null;
48         this.paintingTitle = null;
49         this.artistName = null;
50
51     }
52
53
54     /**
55      * Validate the properties that have been set from this HTTP request,
56      * and return an <code>ActionErrors</code> object that encapsulates any
57      * validation errors that have been found. If no errors are found, return
58      * <code>null</code> or an <code>ActionErrors</code> object with no
59      * recorded error messages.
60      *
61      * @param mapping The mapping used to select this instance
62      * @param request The servlet request we are processing
63      */

64     public ActionErrors validate(ActionMapping mapping,
65                                  HttpServletRequest JavaDoc request) {
66
67         ActionErrors errors = new ActionErrors();
68         if ((paintingTitle == null) || (paintingTitle.length() < 1))
69             errors.add("paintingTitle", new ActionError("error.paintingtitle.required"));
70
71         return errors;
72     }
73 }
Popular Tags