How to use to iterate over a nested list?

后端 未结 1 1742
孤城傲影
孤城傲影 2020-12-04 01:50

Using JSF 2.0, I need to display a table wherein each row contains a link which opens a popup. I have two models: A which has id and List<

相关标签:
1条回答
  • 2020-12-04 02:17

    What you need is to nest another <ui:repeat> tag 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 left that is worth noting is that nested <ui:repeat> tags used to have problems with state management until Mojarra 2.1.15 version (details in jsf listener not called inside nested ui:repeat and in many not so recent questions and their answers), which could result in action listeners not called, etc. but if you're currently on the latest Mojarra JSF implementation - just skip this part altogether.

    0 讨论(0)
提交回复
热议问题