Welcome to the JavaRanch, Sukruti!
We have a "Code" button on our message editor. You can use it to format structured text like
Java code and XML so that it's easier to read. I've applied it to your post.
Avoid using JSTL tags like the "c:forEach". JSTL does not work well with
JSF and JSF has native tags that work better.
In the case of a set of similar UI constructs of varying number arranged vertically, my first preference is the h:dataTable tag. This will layout the constructs as rows in a 2-dimensional grid.
For horizonal layout of constructs or for more free-form layouts, I'd use the ui:repeat tag.
You almost never have to create components dynamically in JSF, and especially not in cases where the size of the generator data is the sole reason, since JSF is designed to adapt the view based on the model.
An alternative for when you need complex controls not available from raw HTML (and thus not from the core JSF tagset) is to use a third-party extension tagset such as RichFaces, IceFaces, PrimeFaces or Apache Tomahawk. These extension sets generally have actual menu tags offering both horizontal and vertical menu layouts already debugged and ready to use.