Tree Mosaic--"DRP"

Source: Internet
Author: User

/** * Sub-leaf node before adding a-number, non-leaf node before adding a + sign * @param conn * @param ID * @param level * @throws SQLException */private void readclient Tree (Connection conn,int id,int level) throws Sqlexception{string sql= "select * from T_client where pid=?"; PreparedStatement Pstmt=null; ResultSet rs=null;try {pstmt=conn.preparestatement (SQL);p Stmt.setint (1, id); Rs =pstmt.executequery (); while (Rs.next ()) {sbtreehtml.append ("<div>");//div begins sbtreehtml.append ("\ n"); for (int i=0;i<level;i++) { Sbtreehtml.append (" \ n"); *///if the traversed node is a leaf node, + name + carriage return, if not traversed by the leaf node,-name Enter//if ("N". Equals (Rs.getstring ("Is_leaf"))) {if (Constants.NO.equals (rs.getstring ("Is_leaf"))) {Sbtreehtml.append (" "+rs.getstring (" name ") +" </a> "); Sbtreehtml.append (" \ n "); Sbtreehtml.append ("<div style=\" display:none;\ "id=\" div "+ rs.getint (" id ") +" \ ">"); sbtreehtml.append ("\ n"); Readclienttree (Conn, rs.getint ("id"), level+1), Sbtreehtml.append ("</div>"); Sbtreehtml.append ("\ n");} Else{sbtreehtml.append (" ");} Else{sbtreehtml.append ("<a href=\" client_node_crud.jsp\ "target=\" clientdispareaframe\ ">" +rs.getString (" Name ") +" </a> ");} Sbtreehtml.append ("\ n");} Sbtreehtml.append ("</div>");//div end SbtreehTml.append ("\ n");}} Finally {Dbutil.close (RS);D butil.close (pstmt);}}

Static class:

/** *  */package com.bjpowernode.drp.util;/** * @ClassName: Constants * @Description: System Common Constants * @author WM * @date January 2016 1st PM 4:14:41 */public class Constants {public static final string no= "N";p ublic static final string yes= "Y";}

JSP page:

<%@ page language= "java" contenttype= "text/html; charset=gb18030 "pageencoding=" GB18030 "%> <% @page import=" com.bjpowernode.drp.basedata.manager.* "%>< Html>

<%=%> Gets the value of a variable on the page

Class to Invoke:

/** *  */package com.bjpowernode.drp.basedata.manager;import com.bjpowernode.drp.basedata.domain.client;/** * @  Classname:clientmanager * @Description: single example implementation * @author WM * @date  */public class Clientmanager {//static class private static Clientmanager instance=new Clientmanager (); Private Clientmanager () {  }//static method public  static Clientmanager getinstance () {return instance;} /** * */  @SuppressWarnings (value = "All") public String Clientmanager () {return new Clienttreereader (). Getclienttreehtmlstring ();} /** * Query reseller and region by ID * @param ID * @return Returns a client object if present, otherwise null */public client Findclientorregionbyid (int id) {return nul l;}}

Page tree structure, although can not support additions and deletions of synchronization, but to achieve a different node display. IMG1 im1 Div1, if it is the parent node, display the + number, name, carriage return, if not the traversed leaf node,-number, name, enter.

Tree Mosaic--"DRP"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.