Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue Retrieving values from a TreeMap of <id, beans> in JSP
    text
    copied!<p>I have been have issues trying to retrieve the values from a treeMap that contains for some time. I have tried several different methods of accessing the data, but the furthest i have gotten was for the JSP to acknowledge there was a Hash or Tree Map, but not actually iterate through it and return data. </p> <p>I have been trying to find the best way to basically sort xml results based on the tag attribute . So I am taking the xml and putting the values of each into a bean, then taking, then placing the beans in a treemap where Key=SortId. Since treema automatically sort the result is a sorted map of XML values. The population of the bean and treeMap works fine the issue is just pulling those values out in to the JSP</p> <p>Well perhaps better illustrating my resulting map will help at least get the point across of what i'm trying to get . The goal is to loop through the newly ordered list and populate my divs with something like </p> <pre><code>&lt;div&gt; Name: ${tileName} &lt;br /&gt; Description: ${tileDescrip} &lt;br /&gt; &lt;img scr="${imagePath}"&gt; &lt;/div&gt; </code></pre> <p>the resulting tree map looks like this </p> <p>sortedHash</p> <pre><code>{0, bean(tileName,tiledescrip,imagePath)} {1, bean(tileName,tiledescrip,imagePath)} {2, bean(tileName,tiledescrip,imagePath)} </code></pre> <p>My issue is that with the code above, I am not getting any values returned back from even the first level iteration of the map even though outputting the map itself does show its there at </p> <pre><code>sortedHash = CTTeamsiteXMLHash@135b24b </code></pre> <p>so the Pseudo flow of what i'm doing</p> <pre><code>Read XML - Iterate -Parse XML Values to bean -Place bean in Treemap&lt;SortId, XML-Bean&gt; -Return TreeMap -Loop through treemap and then pull each bean value out. </code></pre> <p>Here's sample XML</p> <pre><code>&lt;teaser&gt; &lt;sort&gt;1&lt;/sort&gt; &lt;value1&gt;&lt;/value1&gt; &lt;value2&gt;&lt;/value2&gt; &lt;/teaser&gt; </code></pre> <p>My Component</p> <pre><code>public class CTTeamsiteXMLHash { private HashMap&lt;String, Object&gt; xmlHash; private TreeMap&lt;String, Object&gt; sortedHash; public TreeMap&lt;String, Object&gt; getSortedHash() { return sortedHash; } public void setSortedHash(TreeMap&lt;String, Object&gt; sortedHash) { this.sortedHash = sortedHash; } public void setXmlHash(String sortOrder, CTTeamsiteXMLBean bean) { getXmlHash().put(sortOrder, bean); } public HashMap&lt;String, Object&gt; getXmlHash() { return xmlHash; } </code></pre> <p>Here is my failed Attempt at accessing from JSP. if it helps, i am passing the sortedHash in the request as well</p> <pre><code> &lt;jsp:useBean id="sortedHash" class="CTTeamsiteXMLHash" scope="request"/&gt; &lt;c:forEach items="${sortedHash.sortedHash}" var="eachItem"&gt; &lt;c:forEach items="${eachItem.value}" var="anItem"&gt; &lt;c:out value="${anItem.tileName.value}" /&gt; : &lt;c:out value="${anItem.tileDescrip.value}" /&gt; &lt;/c:forEach&gt; &lt;/c:forEach&gt; </code></pre>
 

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