开发者

How to print a LinkedHashMap which is inside a List in jsf datatable?

I am able to print item.srNor but I am not able to print item.details (where details is a LinkedHashMap)

I have got the following datatable in my .xhtml file (jsf)

<h:dataTable id="dt1" value="#{Handler.List}" var="item">

    <h:column>
        <f:facet name="header">
            <h:outputText value="column1" />
        </f:facet>
        <h:outputText value="#{item.srNor}"></h:outputText>
    </h开发者_JS百科:column>

    <h:column>
        <f:facet name="header">
            <h:outputText value="column2" />
        </f:facet>
        <h:outputText value=""></h:outputText>
    </h:column>

    <h:column>
        <f:facet name="header">
            <h:outputText value="column3" />
        </f:facet>
        <h:outputText value=""></h:outputText>
    </h:column>

    <h:column>
        <f:facet name="header">
            <h:outputText value="column4" />
        </f:facet>
        <h:outputText value=""></h:outputText>
    </h:column>


    <f:facet name="footer">
        <h:outputText value="End" />
    </f:facet>

</h:dataTable>

The List in my java class is an Array list.

Any suggestion on this would be really helpful.

Thanks


I understand that #{item.details} returns a Map. You can just access Map values by the associated map key in EL as follows:

#{item.details.somekey}

This resolves under the covers to item.getDetails().get("somekey").

If the key itself contains reserved EL characters like dots and hyphens, then you can also use the brace notation:

#{item.details['some.key']}

This resolves to item.getDetails().get("some.key").

Or if the key itself is to be obtained from another variable, then use the unquoted brace notation

#{item.details[otherbean.key]}

This resolves to item.getDetails().get(otherbean.getKey()).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜