01 /**
02 *
03 * All content copyright (c) 2003-2008 Terracotta, Inc.,
04 * except as may otherwise be noted in a separate copyright notice.
05 * All rights reserved.
06 *
07 */
08 package demo.townsend.form;
09
10 import javax.servlet.http.HttpServletRequest;
11
12 import org.apache.struts.action.ActionErrors;
13 import org.apache.struts.action.ActionForm;
14 import org.apache.struts.action.ActionMapping;
15 import org.apache.struts.action.ActionMessage;
16 import org.apache.struts.action.ActionMessages;
17
18 /**
19 * AddToListForm represents the form data submitted from the display page.
20 * The ActionServlet populates this form when a request for add is received
21 * from the display page.
22 *
23 *@author Terracotta, Inc.
24 */
25 public class AddToListForm extends ActionForm {
26
27 //private Product product;
28 private String id;
29
30 public AddToListForm() {
31 super();
32 resetFields();
33 }
34
35 public void setId(String id) {
36 this.id = id;
37 }
38
39 public String getId() {
40 return id;
41 }
42
43 public ActionErrors validate(ActionMapping mapping, HttpServletRequest req) {
44
45 ActionErrors errors = new ActionErrors();
46
47 if (id == null) {
48 errors.add(ActionMessages.GLOBAL_MESSAGE,
49 new ActionMessage("global.error.addtolist.requiredfield", "product"));
50 }
51 return errors;
52 }
53
54 public void reset(ActionMapping mapping, HttpServletRequest request) {
55 resetFields();
56 }
57
58 protected void resetFields() {
59 id = "";
60 }
61 }
|