日期:2014-05-16  浏览次数:20384 次

jquery数据列表(需要json.jar)
public Map getDsrPwdList(String issubbed, int startIndex,
int maxResults, String typeTree, String nodeName, String col,
String by, String queryType, String queryValue) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
List list = new ArrayList();
try{

StringBuilder select = new StringBuilder("select b.ahqc,b.ajbs  from t_sp_ajjbxx b where   dyyg>''  and  dybg>'' ");

StringBuilder hql = new StringBuilder("from TSpAjjbxx b  where  dyyg>''  and  dybg>'' ");
select.append(" "+queryValue);
hql.append(" "+queryType);

StringBuilder orderby = new StringBuilder(" order by  ");
orderby.append(col).append(" " + by);

String sqlcount = select.toString();

int size=(Integer)daoTool.createSQLQuery("select count(1) from ("+sqlcount+") d  ").uniqueResult();

hql.append(orderby);
list = daoTool.createQuery(hql.toString()).setFirstResult(startIndex).setMaxResults(maxResults).list();

map.put("list", list);
map.put("rows", size);
}catch (Exception e) {
e.printStackTrace();
}
return map;
}
-----------------------------------
public void loadDsrPwdList()  throws Exception{

HttpServletResponse response = ServletActionContext.getResponse();
String page = super.getRequest().getParameter("page");
String pageSize = super.getRequest().getParameter("rp");
String issubbed = super.getRequest().getParameter("subflag") == null ? "0"
: super.getRequest().getParameter("subflag");
String typeTree = super.getRequest().getParameter("typeTree") == null ? ""
: super.getRequest().getParameter("typeTree");
String nodeName = super.getRequest().getParameter("nodeName") == null ? ""
: java.net.URLDecoder.decode(super.getRequest().getParameter(
"nodeName"), "utf-8");
String col = (super.getRequest().getParameter("sortname") == null || super
.getRequest().getParameter("sortname").equals("undefined")) ? "b.ajbs"
: super.getRequest().getParameter("sortname");
String by = (super.getRequest().getParameter("sortorder") == null || super
.getRequest().getParameter("sortorder").equals("undefined")) ? "desc"
: super.getRequest().getParameter("sortorder");
//
StringBuffer hql = new StringBuffer("");

String ah = getRequest().getParameter("qtype") ;
String ahqc= getRequest().getParameter("query");
if (ahqc != null && !ahqc.trim().equals("")) {
hql.append(" and b."+ah+"  like '%" + ahqc + "%' ");
}else{
hql.append(" and 1=2");
}
StringBuffer sql = new StringBuffer("");
sql = new StringBuffer(hql.toString());

int maxResults = Integer.parseInt(pageSize);
int startIndex = (Integer.parseInt(page) - 1) * maxResults;

Map  map= ajcxmanager.getDsrPwdList(issubbed, startIndex, maxResults, typeTree, nodeName, col, by, hql
.toString(), sql.toString());
List<Object> AJList = map.get("list") == null ? null
: (List<Object>) map.get("list");

Map<String, Object> pageInfo = new HashMap<String, Object>();
if (AJList != null && AJList.size() >0) {
List mapList = new ArrayList();
pageInfo.put("page", page);
pageInfo.put("total",map.get("rows"));

for (int i = 0; i < AJList.size(); i++) {
TSpAjjbxx jbxx = (TSpAjjbxx) AJList.get(i);

String fah=jbxx.getAhqc();
String bg =jbxx.getDybg();
String yg = jbxx.getDyyg();
//

String ajbs=jbxx.getAjbs();
List <TSpZxDsr>