Tarun Madaan
Tarun Madaan

Reputation: 401

Passing dynamic value as a key to Map in JSF 2.0

I have a List of keys say 'ListA'. And a map of keys & list say 'MapA'. I need to iterate the 'ListA' & for every key need to get its value from 'MapA'. And those values serve as the model for dataTable.

For this purpose,I'm using h:datatable inside ui:repeat.

<ui:repeat var="entry" value="#{bean.sampleDTO.sampleList}"
    varStatus="row">
    <tr>
        <td>#{entry.key}</td>
        <td><h:datatable value="#{bean.map[#{entry.key}]}" var="row">
                <h:column> 
                    // something
                </h:column>
            </h:datatable></td>
    </tr>
</ui:repeat>

Please consider the value of datatable:

value="#{bean.map[#{entry.key}]}"

The issue is that the key is a variable which I get from #{entry.key}. #{bean.map[#{entry.key}]} is an invalid EL expression as 2 # can't be used.

Thanks, Tarun Madaan

Upvotes: 5

Views: 5073

Answers (1)

Daniel
Daniel

Reputation: 37061

for the el expression : try this

value="#{bean.map[entry.key]}"

you dont need to use #{} inside #{}

Upvotes: 6

Related Questions