How to use <ui: repeat> to iterate over a nested list?
Using JSF 2.0, I need to display a table in which each row contains a link that opens a popup. I have two models: A , which has the id and List<B> properties, and B , which has the id and name properties. In my bean support, I have a List<A> property. In my opinion, I use <ui:repeat> to iterate through List<A> .
The requirement is that depending on the line that the user clicks, it is necessary to display the corresponding List<B> of A However, <ui:repeat> does not accept the nested list assigned in the var attribute. Therefore, I need to make many workarounds that are inefficient.
How to solve this problem effectively?
You will need to insert another <ui:repeat> in your outer iteration:
<ui:repeat value="#{bean.listOfA}" var="a"> ... <ui:repeat value="#{a.listOfB}" var="b"> ... </ui:repeat> </ui:repeat> The only thing worth noting is that the <ui:repeat> nested tags had problems with state management prior to Mojarra version 2.1.15 (details in jsf listener not called inside nested ui: repeat and in many not so recent issues and their answers), which may result in listeners not causing actions, etc., but if you are currently on the latest version of Mojarra JSF, just skip this part as a whole.