Note that there are some explanatory texts on larger screens.

plurals
  1. POBuilding a Tree with MYSQL on Web
    primarykey
    data
    text
    <p>I am trying with JSF + Primefaces to use a list of data that I retrieve from MySQL to build a Tree widget. My problem being that I don't know how make the Tree.</p> <p>I have this data in my MySQL as an example:</p> <pre> id | name | class_id | fl_id ----------------------------------------------- 1 | MARKETING | 0 | 1 2 | COMMERCIAL | 0 | 1 3 | TRADE-MARKETING | 1 | 1 4 | SALES | 1 | 1 5 | RICHARD | 1 | 2 6 | ROGER | 1 | 3 7 | MARIA | 2 | 4 </pre> <p>Which should result in a tree display similar to:</p> <pre> MARKETING >TRADE MARKETING >RICHARD >>ROGER COMMERCIAL >SALES MARIA </pre> <p>As you notice, from the class id, the parent are 0 and the child are 1 (Which I observe is usually null for the father, but I can't change my database).</p> <p>What I have coded so far is similar to this:</p> <pre><code>// Connection with MySQL, get result set, put all the data in my list and use a loop // to count on that list. Then use an "if" condition to tell if 1 or 0, as child or // father for(count = 0, cont &lt; rs.getString("class id").size(); count++) if(rs.getInt("class id") == 1) { } else if(rs.getInt("class id") == 2) { } } // Basically is wrong, because I can't tell what is the end, or leaf. </code></pre> <p>Basically its code that Ive conceptualized but not fully tested yet. I could post all the code, but I can't log in at work (somehow blocks it).</p> <p>I've researched every page on Google I could find to find out how to do this, but it's pretty confusing how to make a tree with MySQL, by far static display is much simpler (from example on Primefaces). I am just a beginner in Java.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload