Search code examples
javajavascriptjsfrichfaces

Iterate through items in a list with richfaces in javascript


Is there a way, in richfaces preferably, to access a Java collection object and loop through the items in a java-script function?

I know richfaces dataTables can access the property and create rows based on each item in the list, but I can't figure out how to replicate that same functionality in a java-script method.

The reason for this, is I need to build an array of object literals, with each object corresponding to a item in the list.


Solution

  • You can use jstl core library to Iterate through List:

    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    
    <c:forEach var="item" items="${bean.items}">
      alert(${item.someField);
    </c:forEach>