Datatable用于显示Tomahawk中对象的ArrayList的Map

时间:2012-08-28 21:09:59

标签: jsf-2 datatable tomahawk

我想在Tomahawk的数据表中显示Map<Integer, ArrayList<ObjectBO>>。我尝试了一些可能的解决方案,但似乎没有任何工作。

<h:panelGrid style="font-family:verdana;font-size:12pt;color:white" columns="1">
    <h:outputText value="Choice 1"></h:outputText>
    <t:dataTable newspaperColumns="1" value="#{startupBean.choiceKeys}" newspaperOrientation="horizontal" var="key">
        <t:column>    
            <h:outputText style="font-family:verdana;font-size:10pt;color:white" value="#{choiceMap[key].ObjectBO.displayName}"/>
        </t:column>
        <t:column>     
            <h:graphicImage width="50" height="50" id="choice" alt="jsf-sun" url="#{choiceMap[Key].ObjectBO.color_url}" value="#{choiceMap[Key].ObjectBO.color_url}"> 
            </h:graphicImage>  
        </t:column> 
    </t:dataTable>
</h:panelGrid>

它的支持bean部分是

public List<Integer> getChoiceKeys() {
    System.out.println("in keys");
    List<Integer> keys = new ArrayList<Integer>();
    keys.addAll(choiceMap.keySet());
    System.out.println("keys " + keys.size());
    return keys;
}

请告诉我如何通过数据表遍历地图。

1 个答案:

答案 0 :(得分:0)

EL中的数字被视为Long。在您的代码中,key中的#{choiceMap[key]}被视为Long,因此地图密钥永远不会匹配,因为Integer不是Long的实例。如果您使用Long代替Integer作为地图密钥,则此方法将有效。

相关问题