发布于 2017-12-24 01:57:08 | 217 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的Java函数式编程,程序狗速度看过来!

Java程序设计语言

java 是一种可以撰写跨平台应用软件的面向对象的程序设计语言,是由Sun Microsystems公司于1995年5月推出的Java程序设计语言和Java平台(即JavaEE(j2ee), JavaME(j2me), JavaSE(j2se))的总称。


这篇文章主要为大家详细介绍了Java easyui树形表格TreeGrid的实现代码,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

自己搞了一下午,终于用JAVA实现了数据网格。记录一下实现的代码。(PS:此处的easyui是1.5版本,楼主只贴了核心的代码)

实现图

JSP页面


<head>
//权限列表
$( document ).ready(function(){
      var parentId = 0;
      $('#tt').treegrid({  
        url:'queryPrivilege.action?parentId='+parentId,  
        idField:'id',  
        treeField:'RecordStatus',
        columns:[[  
          {title:'id',field:'id',width:180}, 
          {field:'RecordStatus',title:'RecordStatus',width:180} ,
          {field:'PrivilegeOperation',title:'PrivilegeOperation',width:180}  
        ]],
        onBeforeExpand:function(row){
          //动态设置展开查询的url
          $(this).treegrid('options').url = 'queryPrivilege.action?parentId='+row.id;  
        }
      }); 
    })
 </script>
 </head>
 <body>
<table id="tt" style="width:600px;height:400px"></table>
</body> 

ACTION层代码


  //输出
    public PrintWriter out()throws IOException{
      HttpServletResponse response=ServletActionContext.getResponse(); 
      response.setContentType("text/html"); 
      response.setContentType("text/plain; charset=utf-8");
      PrintWriter out= response.getWriter();
      return out;
    }  
  public String queryPrivilege() throws IOException{
    returnpd="ok";
    JSONArray array =new JSONArray();    
    array = privilegeService.getMenu(parentId);
    String str=array.toString();
    out().print(str);
    out().flush();
    out().close();
    return returnpd;
  }

Service层接口代码


JSONArray getMenu(int parentId);

ServiceImpl层代码(实现service层)


@Override
  public JSONArray getMenu(int parentId) {
    // TODO Auto-generated method stub
    return (JSONArray)privilegeDao.getMenu(parentId);
  }

Dao层代码


JSONArray getMenu(int parentId);

DaoImpl层代码(实现Dao层)


  @Override
  public JSONArray getMenu(int parentId) {
    // TODO Auto-generated method stub
    String hql="";
    JSONArray array=new JSONArray();
    hql="FROM Privilege p WHERE p.parentID = "+parentId;
    for(Privilege privilege:(List<Privilege>)(getSession().createQuery(hql).list())){
      JSONObject jo=new JSONObject();
      jo.put("id", privilege.getId());
      jo.put("RecordStatus", privilege.getRecordStatus());
      jo.put("parendId",privilege.getParentID());
       if(privilege.getParentID()==0){
          jo.put("state","closed");        
        }
        else{
          jo.put("state","open");
          System.out.println(parentId);
        }
      array.add(jo);
    }
    return array;
  }

数据库一览

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持PHPERZ。



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务