getModuleJson.jsp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <%@ page import="net.sf.json.*"%>
  2. <%@ page pageEncoding="UTF-8"%>
  3. <%@ page
  4. import ="java.util.*"%>
  5. <%@ page language="java"
  6. import="com.sysmodel.datamodel.xmlmodel.ModelFactory,
  7. com.sysmodel.datamodel.xmlmodel.impl.MdpModuleImpl,
  8. com.sysmodel.datamodel.xmlmodel.able.SysModel"%>
  9. <%
  10. String node = request.getParameter("node") == null ? "" : request.getParameter("node");
  11. SysModel sysmodel = ModelFactory.getSysmodel();
  12. ArrayList list1 = new ArrayList();
  13. if(node.equals("root") || node.equals("")){
  14. list1 = sysmodel.getMdpModulesByPcode("");
  15. } else {
  16. list1 = sysmodel.getMdpModulesByPcode(node);
  17. }
  18. StringBuffer sb = new StringBuffer();
  19. sb.append("[");
  20. for (int i = 0; i < list1.size(); i++) {
  21. MdpModuleImpl MdpModuleImpl=(MdpModuleImpl)list1.get(i);
  22. String name=MdpModuleImpl.getName()+"";
  23. String code=MdpModuleImpl.getCode();
  24. if(sysmodel.getMdpModulesByPcode(code).size()>0){
  25. sb.append("{id:'" + code + "',text:'"+name+"',leaf:false},");
  26. } else{
  27. sb.append("{id:'" + code + "',text:'"+name+"',leaf:true},");
  28. }
  29. }
  30. sb.deleteCharAt(sb.lastIndexOf(","));
  31. sb.append("]");
  32. System.out.println("node:"+ node);
  33. System.out.println("fjaksdlf:"+ sb);
  34. out.print(sb.toString());
  35. %>