1 4 package demo.townsend.form; 5 6 import javax.servlet.http.HttpServletRequest ; 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 19 public class AddToListForm extends ActionForm { 20 21 private String id; 23 24 public AddToListForm() { 25 super(); 26 resetFields(); 27 } 28 29 public ActionErrors validate(ActionMapping mapping, HttpServletRequest 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 request) { 41 resetFields(); 42 } 43 44 protected void resetFields() { 45 id = ""; 46 } 47 48 public void setId(String id) { 49 this.id = id; 50 } 51 52 public String getId() { 53 return id; 54 } 55 } 56 57 | Popular Tags |