html :
<ul class="easyui-tree" data-options="url:'../module/getTree.do',method:'get',animate:true,dnd:true"></ul>
java
getTree(){
JsonObject obj= null;
JsonArray ary = null;
Map<String,Object> map =new HashMap<String , Object>();
map.put("parentId", StringUtils.trimToNull(parentId));
List<Moudle> list=service.selectBYParentid(map);
if (modules != null && modules.size() != 0) {
if (modules != null && modules.size() != 0) {
for (Module module : modules) {
object = JsonUtils.toJSONObject(module);
getSubModulesRecursively(object, map);
jsonArray.add(object);
}
}
}
private void getSubModulesRecursively(JSONObject module, Map<String, Object> map) {
module.put("type", "M");
module.put("text", module.get("name"));
// map.put("parentId", module.get("id"));
// module.put("__id__", module.get("id"));
// module.put("id", UUID.randomUUID().toString());
JSONObject object = null;
JSONArray array = new JSONArray();
map.put("moduleId", module.get("id"));
List<Function> functions = functionService.selectByModuleId(map);
if (functions != null && functions.size() != 0) {
for (Function function : functions) {
object = JsonUtils.toJSONObject(function);
object.put("type", "F");
object.put("text", function.getName());
object.put("__id__", function.getId());
object.put("id", UUID.randomUUID().toString());
array.add(object);
}
}
if (array.size() != 0) {
module.put("children", array);
}
}