I've got a situation where I would like to perform nested iterations on a series of options and display the results using JSF. As an example, think of a discussion board. Each comment may contain a parent comment and 0-n child comments. So, my root object would be something like this:
public class MyObject {
...
public List<Comment> getComments();
...
}
And my comments would look like this:
public class Comment {
...
public Comment getParent();
...
public List<Comment> getChildComments();
...
}
I've got all of my entities setup using JPA and they are populated within the database. But, my dilema is, how do I iterate over each comment so I can display its child comments inline? I know I can use <ui:repeat value="#{myObj}" var="comment" />
to iterate over the root-level comments for an object. But, how do I then iterate over the children comments for each of those? And then, how do I iterate over their child comments. And so on, and so on.
Has anyone ever done anything like this? I suppose "Nested Iteration" could really be thought of more as "recursive iteration". Thoughts?