01: /*
02: @COPYRIGHT@
03: */
04: package demo.townsend.form;
05:
06: import javax.servlet.http.HttpServletRequest;
07:
08: import org.apache.struts.action.ActionErrors;
09: 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 id;
23:
24: public AddToListForm() {
25: super ();
26: resetFields();
27: }
28:
29: public ActionErrors validate(ActionMapping mapping,
30: HttpServletRequest req) {
31:
32: ActionErrors errors = new ActionErrors();
33:
34: if (id == null) {
35: errors.add(ActionMessages.GLOBAL_MESSAGE,
36: new ActionMessage(
37: "global.error.addtolist.requiredfield",
38: "product"));
39: }
40: return errors;
41: }
42:
43: public void reset(ActionMapping mapping, HttpServletRequest request) {
44: resetFields();
45: }
46:
47: protected void resetFields() {
48: id = "";
49: }
50:
51: public void setId(String id) {
52: this .id = id;
53: }
54:
55: public String getId() {
56: return id;
57: }
58: }
|