Atitit.列表页面and条件查询的实现最佳实践(1)------设置查询条件and提交查询and返回json数据
Atitit.列表页面and条件查询的实现最佳实践(1)------设置查询条件and提交查询and返回json数据
3. #----show condition page list 1
5. @filter :: set filter condition use or not use ....or save form .... 2
9. Sigle,range>>>> wehere cause 2
1. 1.?配置条件字段@Conditional 1
2. 2.?配置条件字段显示类型为range----@Conditional(displayType?=?displayType.rang,?rangStart?=?rang.start,?rangEnd?=?rang.end,op=op.range)
或者dispayType.single..
作者:: 老哇的爪子 Attilax 艾龙, EMAIL:[email protected]
转载请注明来源: http://blog.csdn.net/attilax
3. #----show condition page list
4. 提交条件查询表单by dwr
//queryBtn_click
Query(1)
function query(isResetPage1)
{
if(isResetPage1==1)
resetPageTo1();
var mp=dwr.util.getFormValues("formx");
elmtC.findByPropertyss_page(mp ,function(data){
//alert("保存成功");
bindTableData(data.rows);
setPageInfo({"total":data.total,"pageSize":10});
});
}
5. @filter :: set filter condition use or not use ....or save form ....
6. @converter
7. #----保存每一个条件map 4 调试
filex.save_safe( core.toJsonStr(QueryPropertyssMap) , "c:\\json2.txt");
8. #====start
for (Field fld : flds) {
Conditional cdt = fld.getAnnotation(Conditional.class);
if (cdt == null)
continue;
.......
9. Sigle,range>>>> wehere cause
10. Hb pageing
11. Ret page map
Map mp=new HashMap();
mp.put("total" ,SafeVal.val( threadLocal_rowsCount.get(),list_sub.size()));
mp.put("rows",list_sub);
12. #----code
public List findByPropertyss(Map QueryPropertyssMap) {
// log.debug("finding GvMaterial instance with property: " +
// propertyName + ", value: " + value);
core. log("---o720--");
core.logMap(QueryPropertyssMap);
filex.save_safe( core.toJsonStr(QueryPropertyssMap) , "c:\\json2.txt");
String propertyName;
Object value;
Criteria c = getSession().createCriteria(GvMaterial.class);
Field[] flds = GvMaterial.class.getDeclaredFields();
for (Field fld : flds) {
try {
String fldName = fld.getName();
if (fldName.startsWith("playtime")) {
String s = "";
}
if (!includeFldInfoPostMap(QueryPropertyssMap, fldName))
continue;
Conditional cdt = fld.getAnnotation(Conditional.class);
if (cdt == null)
continue;
if (cdt.adptr() != None.class) // cstm mode
//
{
List li = adptrMOde(QueryPropertyssMap, c, fld, fldName,
cdt);
addExpresss(c, li);
} else if (cdt.displayType().equals(displayType.single)) {
// if
// (fld.getType().getName().equals(String.class.getName()))
// {
List<Criterion> exprsLi = getExprs(fldName, cdt.op(),
QueryPropertyssMap);
core.log(String.format("--o7f1: dbg fldinfo: %s---%s ",
fldName, QueryPropertyssMap.get(fldName)));
addExpresss(c, exprsLi);
// Restrictions.like(fldName, "%" + + "%")
} else if (cdt.displayType().equals(displayType.rang)) {
List<Criterion> exprsLi = getExprs(fldName, cdt.op(),
QueryPropertyssMap);
core.log(String.format("--o7f1: dbg fldinfo: %s---%s ",
fldName, QueryPropertyssMap.get(fldName)));
addExpresss(c, exprsLi);
}
//
} catch (Exception e) {
core.log(e);
}
// c.add(Restrictions.eq("aname",name));//eq是等于,gt是大于,lt是小于,or是或
}
c.addOrder(Order.desc("materialId"));
List<GvMaterial> list = c.list();
threadLocal_rowsCount.set(list.size());
Object page = QueryPropertyssMap.get("page_page");
List<GvMaterial> list_sub = PagingUtil.getList(list,
QueryPropertyssMap.get("pagesize"), page);
return list_sub;
}
13. 参考
atitit.提升开发效率---MDA 软件开发方式的革命(5)----列表查询建模 - attilax的专栏 - 博客频道 - CSDN.NET.htm
Atitit.列表页面and条件查询的实现最佳实践(1)------设置查询条件and提交查询and返回json数据,古老的榕树,5-wow.com
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。