Note that there are some explanatory texts on larger screens.

plurals
  1. PO<rich:extendedDataTable> <c:forEach> Displaying a table via a "Map of maps"
    primarykey
    data
    text
    <p>I have a data model with structure : <code>TreeMap &lt; String, TreeMap&lt; String, Double&gt;&gt; resultMap;</code> This is stored in a <code>SessionScoped</code> <code>ManagedBean</code>.</p> <p>I am trying to output this via a dynamic <code>&lt; rich:extendedDataTable&gt;</code> where;</p> <ul> <li>Key of first map is the row label</li> <li>Value of first map is a second map ( corresponds to the columns on the row</li> <li>Key of second map is the columns header</li> <li>Value of second map is the columns value</li> </ul> <p>Source Code:</p> <pre><code>&lt;rich:extendedDataTable value="#{queryBean.resultMap.keySet().toArray()}" var="key" frozenColumns="1" styleClass="rich-extdt"&gt; &lt;rich:column width="75px"&gt; &lt;f:facet name="header"&gt; &lt;h:outputText value="Mediation" /&gt; &lt;/f:facet&gt; &lt;h:outputText value="#{key}" /&gt; &lt;/rich:column&gt; &lt;rich:column width="75px"&gt; &lt;f:facet name="header"&gt; &lt;h:outputText value="Test" /&gt; &lt;/f:facet&gt; &lt;h:outputText value="#{queryBean.resultMap[key]}" /&gt; &lt;/rich:column&gt; &lt;c:forEach items="#{queryBean.resultMap[key]}" var="map"&gt; &lt;rich:column width="75px"&gt; &lt;f:facet name="header"&gt; &lt;h:outputText value="#{map.key}" /&gt; &lt;/f:facet&gt; &lt;h:outputText value="#{map.value}" /&gt; &lt;/rich:column&gt; &lt;/c:forEach&gt; &lt;/rich:extendedDataTable&gt; </code></pre> <p>Output:</p> <p><img src="https://i.stack.imgur.com/JtMdF.png" alt="Table output via source code"></p> <p>The first column is correctly outputting the keys of the first map. The second column (used for debugging) is correctly outputting the map structure ( when I apply <code>.keySet()</code> to the structure I do get all the correct keys ). </p> <p>Using: jstl 1.2.0, jsf 2.1 - mojarra, richfaces 4.x, tomcat 7.</p> <p><strong><em>Update:</em></strong></p> <p>As stated <a href="https://stackoverflow.com/questions/16394795/rich-datatable-can-not-use-iterate-variable-for-a-nested-loop/16396322#16396322">here</a>, the <code>&lt; c:forEach&gt;</code> has no access to the <code>&lt; rich:dataTable&gt;</code> attributes, hence unable to use <code>key</code>. Is there any simple workaround to this?</p>
    singulars
    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.
 

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