I have a table in DB which holds child&parent relationships. Now i am trying to display this info in a jsp as a Graph (a sin开发者_高级运维gle child can have multiple parents).
May be i need to use recursive calls in jsp. has anyone come across this kind of work?
any examples/pointers ?
Thanks
Could the hierarchy fit some combination of List / Map data structures? I have some hierarchal data that I'm working on showing in JSP, but it is only three or so levels deep. A Map has a key-value set of lists, a list has other lists, etc. Here is some of my JSP code. It uses expression langauge and jstl tags to keep things simpler:
<section id="content" class="body">
<ol id="posts-list" class="hfeed">
<c:forEach items="${learningEntries}" var="learningEntry">
<li>
<table class="wisiEntry">
<tr>
<td class="pictureCell">
<img class="wisiEntry-pic" src="${learningEntry.imagePath}" />
<div class="tags">
<c:forEach items="${learningEntry.tags}" var="tag">
<a class="tag" href="/tags/${tag.name}">${tag.name}</a>
</c:forEach>
</div>
</td>
<td class="previousNextCell"
<div class="wisiEntry-nextSampleButton">Next</div>
<div class="wisiEntry-previousSampleButton">Previous</div>
<br />
<div class="wisiEntry-addTagButton">Tag</div>
<div class="wisiEntry-addCommentButton">Comment</div>
<br />
<div class="wisiEntry-uploadButton">Upload</div>
</td>
<td>
<!-- ERROR HAPPENS HERE. Samples should not be null -->
<c:forEach items="${learningEntry.samples}" var="sample" varStatus = "status">
<table class="sampleEntry" ${status.first ? '' : 'style = "display:none"'}>
<tr>
<td class="sampleCell">
<p class="description">
${sample.description}
</p>
...
I believe this will help you. This JSP tree can load parent child relationships very well. I have used the Velocity template and JSP Tag class. The entire source code is available too.
精彩评论