.qtipTable {
margin: 0;
padding: 0;
font-size: 12px;
}
.qtipBody {
border-right: 1px solid #b5daff;
border-top: 1px solid #b5daff;
font-family: 微软雅黑,宋体,tahoma, Arial, Verdana, sans-serif;
font-size: 12px;
}
.qtipBody th {
border-left: 1px solid #b5daff;
border-bottom: 1px solid #b5daff;
vertical-align: middle;
background-color: #d0e8ff;
text-align:center;
width:100px;
}
.qtipBody td {
border-left: 1px solid #b5daff;
border-bottom: 1px solid #b5daff;
color: black;
}
.money_right{
text-align:right;
padding-right:2px;
}
/**
* 根据list 返回table
* @param titlenm 标题名称
* @param pType Class
* @param pList 结果集
* @param pFieldNames 列名
* 例如:makeHTMLTable("rsvmain.title.rsvoccudtl", Rsvoccudtl.class, rsvoccudtlList, "blockId","rmcnt")
* @return
*/
public <T> String makeHTMLTable(String titlenm, Class<T> pType, List<T> pList, String... pFieldNames)
throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException,
NoSuchMethodException {
String wFuncnm, wResult = "<div style='margin-bottom: 5px;'><span style='font-size:14px;font-weight:bold;'>"
+ ApplicationContextUtil.getMessage(titlenm)
+ "</span></div><div class='qtipTable'><table class='qtipBody' cellspacing='0' border=0 width='100%'><tr>";
//获得Class
String wClassnm = pType.getName().substring(pType.getName().lastIndexOf(".") + 1);
//遍历标题
for (String fnm : pFieldNames) {
wResult += "<th>" + ApplicationContextUtil.getMessage(wClassnm + "." + fnm) + "</th>";
}
wResult += "</tr>";
Iterator<T> iterator = pList.iterator();
while (iterator.hasNext()) {
wResult += "<tr>";
T t = (T) iterator.next();
for (String fnm : pFieldNames) {
wFuncnm = "get" + fnm.substring(0, 1).toUpperCase() + fnm.substring(1);
String tmpString = pType.getMethod(wFuncnm).invoke(t).toString();
//判断如果是数字,则右对齐
if (tmpString.matches("^[-+]?(([0-9]+)([.]([0-9]+))?|([.]([0-9]+))?)$")) {
wResult += "<td class='money_right'>" + tmpString + "</td>";
} else {
wResult += "<td>" + tmpString + "</td>";
}
}
wResult += "</tr>";
}
wResult += "</table></div>";
return wResult;
}