📄 customerinfoform.java
字号:
package itso.strutsweb.forms;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
/**
* Form bean for a Struts application.
* Users may access 5 fields on this form:
* <ul>
* <li>customerNumber - [your comment here]
* <li>custumerName - [your comment here]
* <li>accountNumber - [your comment here]
* <li>accountNumbers - [your comment here]
* <li>validateKey - [your comment here]
* </ul>
* @version 1.0
* @author
*/
public class CustomerInfoForm extends ActionForm {
private String customerNumber = null;
private String customerName = null;
private String accountNumber = null;
private String[] accountNumbers = null;
private String validateKey = null;
/**
* Get customerNumber
* @return String
*/
public String getCustomerNumber() {
return customerNumber;
}
/**
* Set customerNumber
* @param <code>String</code>
*/
public void setCustomerNumber(String c) {
customerNumber = c;
}
/**
* Get custumerName
* @return String
*/
public String getCustomerName() {
return customerName;
}
/**
* Set custumerName
* @param <code>String</code>
*/
public void setCustomerName(String c) {
customerName = c;
}
/**
* Get accountNumber
* @return String
*/
public String getAccountNumber() {
return accountNumber;
}
/**
* Set accountNumber
* @param <code>String</code>
*/
public void setAccountNumber(String a) {
accountNumber = a;
}
/**
* Get accountNumbers
* @return String[]
*/
public String[] getAccountNumbers() {
return accountNumbers;
}
/**
* Set accountNumbers
* @param <code>String[]</code>
*/
public void setAccountNumbers(String[] a) {
accountNumbers = a;
}
/**
* Get validateKey
* @return String
*/
public String getValidateKey() {
return validateKey;
}
/**
* Set validateKey
* @param <code>String</code>
*/
public void setValidateKey(String v) {
validateKey = v;
}
/**
* Constructor
*/
public CustomerInfoForm() {
super();
}
public void reset(ActionMapping mapping, HttpServletRequest request) {
// Reset values are provided as samples only. Change as appropriate.
customerNumber = null;
customerName = null;
accountNumber = null;
accountNumbers = null;
validateKey = null;
}
public ActionErrors validate(
ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
// Validate the customerNumber
if ("1".equals(validateKey)) {
if (customerNumber == null || customerNumber.trim().length() == 0)
errors.add(
ActionErrors.GLOBAL_ERROR,
new ActionError("error.missing.customerId"));
else if (customerNumber.trim().length() != 3)
errors.add(
ActionErrors.GLOBAL_ERROR,
new ActionError("error.invalid.customerId"));
}
// Validate the accountNumber - defer to action class
if ("2".equals(validateKey)) {}
return errors;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -