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!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With