Iterate through List<String> using JSF 2
jsf, jsf-2
Solution
You can use `<ui:repeat>`:
<ui:repeat value="#{bean.myList}" var="value">
#{value} <br />
</ui:repeat>
If you're not sure if you should use `<h:dataTable>` or `<ui:repeat>`, you can check an example that mkyong provides here: JSF 2 repeat tag example
In short: `<h:dataTable>` renders a `<table>` HTML component, while `<ui:repeat>` gives you the flexibility to choose how to display the data.
Problem
I have this java code. ``` List<String> myList = new ArrayList<String>(); myList.add("Hello"); myList.add("World"); ``` I need to loop through the list to display those values in a webpage. I thought of using a dataTable but I don't know how to retrieve each entry on the list. Ideas? Thanks!