Skip to Main Content
Mastering JavaServer Faces 2.2
book

Mastering JavaServer Faces 2.2

by Anghel Leonard
June 2014
Intermediate to advanced content levelIntermediate to advanced
578 pages
12h 2m
English
Packt Publishing
Content preview from Mastering JavaServer Faces 2.2

Generating tables with the JSF API

JSF tables can be programmatically generated as well. The JSF API provides comprehensive support to accomplish such tasks. First, you prepare the place where the generated table will be added, as follows:

<h:body>
  <h:form id="tableForm">     
    <h:panelGrid id="myTable">                
    </h:panelGrid>
    <h:commandButton value="Add Table" action="#{playersBean.addTable()}"/>
  </h:form>        
</h:body> 

The idea is simple: when the button labeled Add Table is clicked, the generated table should be attached in the <h:panelGrid> tag identified by the myTable ID.

Before creating a JSF table in a programmatic fashion, you need to know how to create a table, a header/footer, a column, and so on. Let's have a short overview as follows—the code is self-explanatory ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

JavaServer Faces

JavaServer Faces

Hans Bergsten

Publisher Resources

ISBN: 9781782176466Supplemental Content