easyui-combotree 值传输问题

ddsseser 发布于 2015/06/15 11:43
阅读 1K+
收藏 0

[{"id":1,"text":"ssssss","pid":0,"state":"closed"},

{"id":2,"text":"aaaaaaa","pid":0,"state":"closed"},

{"id":5,"text":"dddddddd","pid":0,"state":"closed"},

{"id":10,"text":"lllllll","pid":0,"state":"closed"},

{"id":15,"text":"eeeeeeee","pid":0,"state":"closed"},]

上面是后台拿到的数据,前台传值的时候报错


<!--这是页面上的代码 -->
<script type="text/javascript">
$(function(){
	debugger;
     $('#areaName').combotree({		 
	url:'${pageContext.request.contextPath}/sys/network/getComBoTree'});  });</script>
<input class="easyui-combotree" id="areaName" style="width:170px;" >
//后台代码


@RequestMapping(value = "/getComBoTree", method = RequestMethod.POST)
public @ResponseBody JsonResponse getComBoTree(@RequestParam(value ="id", required = false) String id) {
if(id!=null){
log.debug("param map={}", id);
//封装查询条件
PageDomain<Network> pd = new PageDomain<Network>();
pd.addWhereObjList(new WhereObj("PID", "=", id));
pd.setOrderBy("ID asc ");
List<Network> resultsList = new ArrayList<Network>();
List<ComBoTree> treeList = new ArrayList<ComBoTree>();
try {
//查询结果集
List<Network> networkList = netWorkBmo.findDataByCondition(pd);
resultsList.addAll(networkList);
log.debug("resultsList={}", JsonUtil.toString(resultsList));
//遍历 结果集 做成 json 格式
for(Iterator iterator = resultsList.iterator();iterator.hasNext();){
       Network ntwk = (Network) iterator.next();
       ComBoTree t = new ComBoTree();
       t.setId(ntwk.getId());
       t.setText(ntwk.getName());       
       t.setParentId(ntwk.getPid());
       if(loadNetworkByChildren(id).size()>0){
 t.setState("closed");
}else{
 t.setState("open");

     /*  Map<String,Object> map = new  HashMap<String,Object>();
        map.put("ParentId", ntwk.getPid());
        t.setAttributes(map);*/
       treeList.add(t);
}
   log.debug(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>treeList={}", JsonUtil.toString(treeList));
return super.successed(treeList);
//model.addAttribute("networkTerminalPm", networkTerminalPm);
} catch (BusinessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}else{
id="0";
getComBoTree(id);
}
return null;
}
public List<Network> loadNetworkByChildren(String id) {
log.debug("param map={}", id);
PageDomain<Network> pd = new PageDomain<Network>();
pd.addWhereObjList(new WhereObj("PID", "=", id));
pd.setOrderBy("ID asc ");
List<Network> resultsList = new ArrayList<Network>();
log.debug("param map={}", JsonUtil.toString(resultsList));

try {
List<Network> networkList = netWorkBmo.findDataByCondition(pd);
resultsList.addAll(networkList);
log.debug("resultsList={}>>>>>>>>>>>>>>>>>>>>", JsonUtil.toString(resultsList));
} catch (BusinessException e) {
e.printStackTrace();
}
return resultsList;
}

加载中
0
d
ddsseser
 使用递归方法不当。应该使用 @RequestMapping(value = "/getComBoTree", method = RequestMethod.POST)

public @ResponseBody JsonResponse getComBoTree(@RequestParam(value ="id", required = false,defaultValue="0") String id) { }

请求方式

返回顶部
顶部