CategoryListAJAX.jsp
上传用户:sxychgz
上传日期:2019-04-21
资源大小:4772k
文件大小:1k
源码类别:

电子政务应用

开发平台:

Java

  1. <%@ page language="java" contentType="text/html; charset=GB18030"
  2.     pageEncoding="GB18030"%>
  3. <%@ page import="com.bjsxt.shopping.category.*, java.util.*"%>
  4. <%
  5. List<Category> categories = CategoryService.getInstance().getTopCategories();
  6. %>
  7. <html>
  8. <head>
  9. <script language="javascript" src="script/TV20.js"></script>
  10. <script language="javascript">
  11. var req;
  12. var gKey;
  13. function init() {
  14. if(window.XMLHttpRequest) {
  15. req = new XMLHttpRequest();
  16. } else if (window.ActiveXObject) {
  17. req = new ActiveXObject("Microsoft.XMLHTTP");
  18. }
  19. }
  20. function myLabelDblClick(key, parentKey) {
  21. if(findNode(key).subitems.length > 0) return;
  22. init();
  23. gKey = key;
  24. var url = "GetCategoryChilds2.jsp?id=" + escape(key);
  25. req.open("GET", url, true);
  26. req.onreadystatechange = callback;
  27. req.send(null);
  28. }
  29. function callback() {
  30. if(4 == req.readyState) {
  31. if(200 == req.status) {
  32. eval(req.responseText);
  33. var node = findNode(gKey);
  34. if(node.subitems.length > 0) {
  35. node.refresh();
  36. node.open();
  37. }
  38. }
  39. }
  40. }
  41. </script>
  42. </head>
  43. <body>
  44. <script language="javascript">
  45. <!--
  46. addListener("dblclick", "myLabelDblClick");
  47. addNode(-1,0,"类别","images/top.gif");
  48. <%
  49. for(int i=0; i<categories.size(); i++) {
  50. Category c = categories.get(i);
  51. %>
  52. addNode(<%=c.getPid()%>,<%=c.getId()%>,"<%=c.getName()%>","images/top.gif");
  53. <%
  54. }
  55. %>
  56. showTV();
  57. -->
  58. </script>
  59. </body>
  60. </html>