easyuiの木

3483 ワード


//easyuiのツリーはjsonフォーマットに接続する必要があります.
[{
  • "id":1,

  • "text":"Folder1",
  • "iconCls":"icon-save",

  • "children":[{
  • "text":"File1",

  • "checked":true
  • },{

  • "text":"Books",
  • "state":"open",

  • "attributes":{
  • "url":"/demo/book/abc",

  • "price":100
  • },

  • "children":[{
  • "text":"PhotoShop",

  • "checked":true
  • },{

  • "id": 8,
  • "text":"Sub Bookds",

  • "state":"closed"
  • }]

  • }]
  • },{

  • "text":"Languages",
  • "state":"closed",

  • "children":[{
  • "text":"Java"

  • },{
  • "text":"C#"

  • }]
  • }]   
  • //	public  void main(String[] args) {
    //	
    //		JSONArray ja=new JSONArray();
    //		JSONObject jo = new JSONObject();
    //		JSONObject jo2 = new JSONObject();
    //		BaseDao dao=getDao();
    //		try{
    //			List<OrgModel> list=dao.selectForList("org.getOrgByPid",model);
    //			List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
    //			OrgModel m;
    //			for(int i=0; i<list.size();i++){
    //				m = list.get(i);
    //				jo2= new JSONObject();
    //				jo2.put("pid",);
    //				jo2.put("text", "parent"+i);
    //				for (int j=0; j<list2.size(); j++) {
    //					jo = new JSONObject();
    //					jo.put("id", j);
    //					jo.put("text", "Folder"+j);
    //					ja.put(jo);
    //				}
    //				jo2.put("childern", ja.toString());
    //				System.out.println(jo2.toString());
    //				}
    //		} catch (Exception e) {
    //			e.printStackTrace();
    //		}
    //	}
  • // youthWeb 
    	public void getYouthListWeb(){
    		JSONArray ja=new JSONArray();//json 
    		JSONObject jo;//json 
    		BaseDao dao=getDao();
    		try {
    			model.setPid("1");
    			List<OrgModel> list=dao.selectForList("org.getListWebByPid",model);
    			OrgModel m;
    			 jo=new JSONObject();
    			 jo.put("id","");
    			 jo.put("text","");
    			 ja.put(jo);
    			 JSONObject jo1=new JSONObject();
    			 jo1.put("id","");
    			 jo1.put("text","");
    			 ja.put(jo1);
    			 JSONObject jo2=new JSONObject();
    			 jo2.put("id","");
    			 jo2.put("text","");
    			 ja.put(jo2);
    			 System.out.println(ja.toString());
    			for (int i=0; i<list.size();i++) {
    				m = list.get(i);
    				jo = new JSONObject();
    				jo.put("id", m.getOrgCode());
    				jo.put("text", m.getOrgName());
    				ja.put(jo);
    			}
    			System.out.println(" "+ja.toString());
    			this.doResponse(ja.toString());
    		} catch (Exception e) {
    			logger.error(" :", e);
    			this.doResponse("");
    		}
    	}