Tabbed Panels with Dynamic Tabs

First, note that I am doing this with c:forEach, since that is what you were trying to do. However, p:tabView has a builtin iteration feature that presumably accomplishes the same thing with a bit less code. The 5.1 User Guide has an example, but I checked the 3.4 and 4.0 user's guides, and they both mentioned the same feature. But, again, presumably this builtin iteration feature works the same way as does the approach using c:forEach.

From what I understand, the reason you want dynamic tabs is because you have a variable number of Java objects that have associated content to display. I looked at three ways to display this dynamic content: generating dynamic content from bean properties (no HTML in the dynamic values), generating dynamic content from bean properties (with HTML tags in the dynamic values), and generating dynamic content by computing the location of include files. Examples and discussion of each of these is below.


All code from the coreservlets.com J2EE tutorials: JSF 2.2, PrimeFaces, Java 7 programming, Java 8 lambdas and streams, Hadoop, Ajax with jQuery, GWT, Spring, Hibernate, JPA, SOAP-based and RESTful Web Services, Android development, servlets, and JSP. There are also live instructor-led training courses on the same Java EE topics: JSF 2.2, PrimeFaces, Java 7 programming, Java 8 lambdas and streams, Hadoop, Ajax with jQuery, GWT, Spring, Hibernate, JPA, SOAP-based and RESTful Web Services, Android development, servlets, and JSP. Email info@coreservlets.com to inquire about customized versions of these courses taught onsite at your organization. Also see the JSF 2.2 tutorial, the PrimeFaces tutorial, and information about Marty Hall, the training course instructor.