Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing dynamic value as a key to Map in JSF 2.0

Tags:

el

jsf-2

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

like image 858
Tarun Madaan Avatar asked Mar 28 '12 09:03

Tarun Madaan


1 Answers

for the el expression : try this

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

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

like image 200
Daniel Avatar answered Nov 14 '22 00:11

Daniel