orderentryform.java

来自「BEA WebLogic Server 8.1大全 = BEA webLogic」· Java 代码 · 共 77 行

JAVA
77
字号
package myApp.FormBeans;import javax.servlet.http.HttpServletRequest;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionError;import org.apache.struts.action.ActionErrors;import org.apache.struts.action.ActionMapping;public class OrderEntryForm extends ActionForm {  public OrderEntryForm() {  }  private String item = null;  private String qty = null;  private String date = null;  public String getItem() {         return this.item;   }  public void setItem(String i){         this.item = i;   }  public String getQty() {          return this.qty;    }   public void setQty(String i){          this.qty = i;    }    public String getDate() {           return this.date;     }    public void setDate(String i){           this.date = i;     }  public void reset(ActionMapping mapping, HttpServletRequest request) {          this.item = null;          this.qty = null;          this.date = null;  }  public ActionErrors validate(ActionMapping mapping,                                   HttpServletRequest request) {          ActionErrors errors = new ActionErrors();          if ((item == null) || (item.length() < 1))              errors.add("item", new ActionError("error.item.required"));          if (formatQty(qty))              errors.add("qty", new ActionError("error.qty.invalid"));            if (formatDate(date))              errors.add("date", new ActionError("error.date.invalid"));          return errors;      }private boolean formatQty(String q){      try{       int qt = Integer.parseInt(q);      if(qt<0)        return true;      }catch(Exception e){        return true;      }      return false;}private boolean formatDate(String d){try{      java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("MM/dd/yyyy");      df.parse(d);}catch(Exception e){      return true;      }return false;}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?