📄 moneyform.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package org.myrose.form;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
/**
* MyEclipse Struts Creation date: 01-02-2008
*
* XDoclet definition:
*
* @struts.form name="moneyForm"
*/
public class MoneyForm extends ActionForm {
private String money;
private String otherid;
public String getOtherid() {
return otherid;
}
public void setOtherid(String otherid) {
this.otherid = otherid;
}
/**
* Method validate
*
* @param mapping
* @param request
* @return ActionErrors
*/
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
String path = mapping.getParameter();
ActionErrors errors = new ActionErrors();
String smoney = this.validate(money);
String sid = this.validate(otherid);
if (path.equals("dodisburse")) {
if (smoney.equals("null")) {
errors.add("disburse_money_null", new ActionMessage("disburse.money.null"));
} else if (smoney.equals("error")) {
errors.add("disburse_money_error", new ActionMessage("disburse.money.error"));
}
} else if (path.equals("dodeposit")) {
if (smoney.equals("null")) {
errors.add("deposit_money_null", new ActionMessage("deposit.money.null"));
} else if (smoney.equals("error")) {
errors.add("deposit_money_error", new ActionMessage("deposit.money.error"));
}
}else if( path.equals("dotransfer")){
if (smoney.equals("null")) {
errors.add("transfer_money_null", new ActionMessage("transfer.money.null"));
} else if (smoney.equals("error")) {
errors.add("transfer_money_error", new ActionMessage("transfer.money.error"));
}else if(sid.equals("null")){
errors.add("transfer_otherid_null", new ActionMessage("transfer.otherid.null"));
}else if(sid.equals("error")){
errors.add("transfer_otherid_error", new ActionMessage("transfer.otherid.error"));
}
}
return errors;
}
/**
* Method reset
*
* @param mapping
* @param request
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
money = "";
}
/**
* Returns the money.
*
* @return Double
*/
public String getMoney() {
return money;
}
/**
* Set the money.
*
* @param money
* The money to set
*/
public void setMoney(String money) {
this.money = money;
}
private String validate(String str) {
String string = "";
if (str == null || str.trim().equals("")) {
string = "null";
} else {
int index = str.indexOf(".");
int lastindex = str.lastIndexOf(".");
if (index != lastindex) {
string = "error";
} else {
String s = str;
if (index != -1) {
s = str.substring(index, index + 1);
}
for (int i = 0; i < s.length(); i++) {
char c = (s.toCharArray())[i];
if (!Character.isDigit(c)) {// 判断是否为数字
string = "error";
break;
}
}
}
}
return string;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -