KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > demo > townsend > form > AddToListForm


1 /*
2 @COPYRIGHT@
3 */

4 package demo.townsend.form;
5
6 import javax.servlet.http.HttpServletRequest JavaDoc;
7
8 import org.apache.struts.action.ActionErrors;
9 import org.apache.struts.action.ActionForm;
10 import org.apache.struts.action.ActionMapping;
11 import org.apache.struts.action.ActionMessage;
12 import org.apache.struts.action.ActionMessages;
13
14 /**
15  * AddToListForm represents the form data submitted from the display page.
16  * The ActionServlet populates this form when a request for add is received
17  * from the display page.
18  */

19 public class AddToListForm extends ActionForm {
20     
21   //private Product product;
22
private String JavaDoc id;
23   
24   public AddToListForm() {
25     super();
26     resetFields();
27   }
28
29   public ActionErrors validate(ActionMapping mapping, HttpServletRequest JavaDoc req ){
30       
31       ActionErrors errors = new ActionErrors();
32
33     if(id == null) {
34       errors.add(ActionMessages.GLOBAL_MESSAGE,
35               new ActionMessage("global.error.addtolist.requiredfield", "product" ));
36     }
37     return errors;
38   }
39
40   public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
41     resetFields();
42   }
43
44   protected void resetFields() {
45     id = "";
46   }
47
48   public void setId(String JavaDoc id) {
49     this.id = id;
50   }
51
52   public String JavaDoc getId() {
53     return id;
54   }
55 }
56
57
Popular Tags