📄 oldfunctions.jsp
字号:
{
if ( value.equals("on") )
entity.set(curField.getName(), "Y");
else if ( value.equals("off") )
entity.set(curField.getName(), "N");
else
entity.set(curField.getName(), value);
}
else
entity.set(curField.getName(), value);
} else if(fieldType.equals("java.sql.Timestamp") || fieldType.equals("Timestamp")) {
if(value.trim().length() == 0){
entity.set(curField.getName(), null);
} else {
try { entity.set(curField.getName(), new Timestamp(timeFormat.parse(value).getTime()));
} catch (ParseException e) { e.printStackTrace();
} //WTD: Implement error processing for ParseException. i.e. get rid of the printStackTrace()
}
} else if(fieldType.equals("java.sql.Time") || fieldType.equals("Time")) {
if(value.trim().length() == 0){
entity.set(curField.getName(), null);
} else {
try { entity.set(curField.getName(), new Time(timeFormat.parse(value).getTime()));
} catch (ParseException e) { e.printStackTrace();
} //WTD: Implement error processing for ParseException. i.e. get rid of the printStackTrace()
}
} else if(fieldType.equals("java.util.Date")) {
if(value.trim().length() == 0) {
entity.set(curField.getName(), null);
} else {
try { entity.set(curField.getName(), new java.sql.Date(dateFormat.parse(value).getTime()));
} catch (ParseException e) { e.printStackTrace();
} //WTD: Implement error processing for ParseException. i.e. get rid of the printStackTrace()
}
} else if(fieldType.equals("java.sql.Date") || fieldType.equals("Date")) {
if(value.trim().length() == 0) {
entity.set(curField.getName(), null);
} else {
try { entity.set(curField.getName(), new java.sql.Date(dateFormat.parse(value).getTime()));
} catch (ParseException e) { e.printStackTrace();
} //WTD: Implement error processing for ParseException. i.e. get rid of the printStackTrace()
}
} else if(fieldType.equals("java.lang.Integer") || fieldType.equals("Integer")) {
if(value.trim().length() == 0) value = "0";
entity.set(curField.getName(), Integer.valueOf(value));
}
else if(fieldType.equals("java.lang.Long") || fieldType.equals("Long")) {
if(value.trim().length() == 0) value = "0";
entity.set(curField.getName(), Long.valueOf(value));
}
else if(fieldType.equals("java.lang.Float") || fieldType.equals("Float")) {
if(value.trim().length() == 0) value = "0.0";
entity.set(curField.getName(), Float.valueOf(value));
}
else if(fieldType.equals("java.lang.Double") || fieldType.equals("Double")) {
if(value.trim().length() == 0 || value == null) value = "0";
entity.set(curField.getName(), Double.valueOf(value));
}
return entity;
}
String getFieldValue(List l, String fieldName, String equalsValue, String returnFieldName){
Iterator i = l.iterator();
GenericEntity genericEntity = null;
String retVal = "";
//TODO: add StringTokenizer to parse multiple fields.
while(i.hasNext()){
genericEntity = (GenericValue)i.next();
if(String.valueOf(genericEntity.get(fieldName)).equals(equalsValue))
retVal = String.valueOf(genericEntity.get(returnFieldName));
}
return retVal;
}
String getFieldValue(HttpServletRequest request, String fieldName){
return (request.getParameter(fieldName) != null ? request.getParameter(fieldName) : "");
}
Vector getGenericValue(List l, String fieldName, String equalsValue){
Vector returnVector = new Vector();
GenericValue genericValue = null;
GenericValue genericValues[] = (GenericValue[])l.toArray(new GenericValue[0]);
for(int i=0;i<genericValues.length;i++){
genericValue = (GenericValue)genericValues[i];
if(String.valueOf(genericValue.get(fieldName)).equals(equalsValue))
returnVector.add(genericValue);
}
return returnVector;
}
String getDateTimeFieldValue(List l, String fieldName, String equalsValue, String returnFieldName, String dateFormatString){
GenericValue genericValue = null;
GenericValue genericValues[] = (GenericValue[])l.toArray(new GenericValue[0]);
String retVal = "";
SimpleDateFormat dateFormat = new SimpleDateFormat(dateFormatString);
for(int i=0;i<genericValues.length;i++){
genericValue = genericValues[i];
try{
if(dateFormat.parse(genericValue.getString(fieldName)).equals(dateFormat.parse(equalsValue)))
retVal = String.valueOf(genericValue.get(returnFieldName));
} catch (ParseException e) {
e.printStackTrace();
}
}
return retVal;
}
Vector getDateTimeGenericValue(List l, String fieldName, String equalsValue, String dateFormatString){
Vector returnVector = new Vector();
GenericValue genericValue = null;
GenericValue genericValues[] = (GenericValue[])l.toArray(new GenericValue[0]);
String retVal = "";
SimpleDateFormat dateFormat = new SimpleDateFormat(dateFormatString);
for(int i=0;i<genericValues.length;i++){
genericValue = genericValues[i];
try{
if(dateFormat.parse(genericValue.getString(fieldName)).equals(dateFormat.parse(equalsValue)))
returnVector.add(genericValue);
} catch (ParseException e) {
e.printStackTrace();
}
}
return returnVector;
}
String getStatesDropDown(String name, String selected){
if(name == null) return null;
StringBuffer returnString = new StringBuffer();
returnString.append("<select class=\"\" name=\"" + name + "\" >");
returnString.append("<option " + (selected == null || selected.equals("") ? "selected" : "") + " >");
returnString.append("<option " + (selected != null && selected.equals("AK") ? "selected" : "") + " >AK");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("AL") ? " selected" : "") + ">AL");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("AR") ? " selected" : "") + ">AR");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("AZ") ? " selected" : "") + ">AZ");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("CA") ? " selected" : "") + ">CA");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("CO") ? " selected" : "") + ">CO");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("CT") ? " selected" : "") + ">CT");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("DC") ? " selected" : "") + ">DC");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("DE") ? " selected" : "") + ">DE");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("FL") ? " selected" : "") + ">FL");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("GA") ? " selected" : "") + ">GA");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("GU") ? " selected" : "") + ">GU");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("HI") ? " selected" : "") + ">HI");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("IA") ? " selected" : "") + ">IA");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("ID") ? " selected" : "") + ">ID");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("IL") ? " selected" : "") + ">IL");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("IN") ? " selected" : "") + ">IN");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("KS") ? " selected" : "") + ">KS");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("KY") ? " selected" : "") + ">KY");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("LA") ? " selected" : "") + ">LA");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("MA") ? " selected" : "") + ">MA");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("MD") ? " selected" : "") + ">MD");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("ME") ? " selected" : "") + ">ME");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("MI") ? " selected" : "") + ">MI");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("MN") ? " selected" : "") + ">MN");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("MO") ? " selected" : "") + ">MO");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("MS") ? " selected" : "") + ">MS");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("MT") ? " selected" : "") + ">MT");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("NC") ? " selected" : "") + ">NC");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("ND") ? " selected" : "") + ">ND");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("NE") ? " selected" : "") + ">NE");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("NH") ? " selected" : "") + ">NH");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("NJ") ? " selected" : "") + ">NJ");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("NM") ? " selected" : "") + ">NM");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("NV") ? " selected" : "") + ">NV");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("NY") ? " selected" : "") + ">NY");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("OH") ? " selected" : "") + ">OH");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("OK") ? " selected" : "") + ">OK");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("OR") ? " selected" : "") + ">OR");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("PA") ? " selected" : "") + ">PA");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("PR") ? " selected" : "") + ">PR");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("RI") ? " selected" : "") + ">RI");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("SC") ? " selected" : "") + ">SC");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("SD") ? " selected" : "") + ">SD");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("TN") ? " selected" : "") + ">TN");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("TX") ? " selected" : "") + ">TX");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("UT") ? " selected" : "") + ">UT");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("VA") ? " selected" : "") + ">VA");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("VI") ? " selected" : "") + ">VI");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("VT") ? " selected" : "") + ">VT");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("WA") ? " selected" : "") + ">WA");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("WI") ? " selected" : "") + ">WI");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("WV") ? " selected" : "") + ">WV");
returnString.append("<option" + (selected != null && selected.equalsIgnoreCase("WY") ? " selected" : "") + ">WY");
returnString.append("</select>");
return returnString.toString();
}
%>
<!-- [oldFunctions.jsp] End -->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -