JSF column Tag

This section tells you about the JSF html column tag which is used for creating columns of a table. This tag creates a data column inside a data table.

JSF column Tag

JSF column Tag

    

This section tells you about the JSF html column tag which is used for creating columns of a table. This tag creates a data column inside a data table. By this table you can specify number of column and fix these with some specific values. You can specify the value for specific column by using data array. JSF data table creates multiple rows up to the length of array or number of elements associated with the data table.

This section provides you a complete code of a program in which the column tags are used inside the data table. This program will help you for the procedure of using column tag for creating columns in a table.

Code Description:

<%@ page contentType="text/html" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

<f:view>
<html>
   <head><title>jsf h:column example</title></head>

   <body>
  <h:dataTable border="1">
  <f:facet name="header">
  <h:outputText value="This is header."/>
  </f:facet>
  <h:column>
  <f:facet name="header">
   <h:outputText value="Student"/>
  </f:facet>
  </h:column>
  <h:column>
  <f:facet name="header">
   <h:outputText value="Marks" />
  </f:facet>
  </h:column>
  <h:column>
  <f:facet name="header">
   <h:outputText value="Percent" />
  </f:facet>
  </h:column>
  <f:facet name="footer">
   <h:outputText value="This is footer."/>
  </f:facet>
  </h:dataTable>
   </body>
</html>
</f:view>

Rendered Output:

HTML Source Code:

<html>
   <head><title>jsf h:column example</title></head>

 <body>
 <table border="1">
 <thead>
  <tr><th colspan="3" scope="colgroup">This is header.</th></tr>
    <tr>
       <th scope="col">Student</th>
          <th scope="col">Marks</th>
            <th scope="col">Percent</th>
           </tr>
        </thead>
        <tfoot>
       <tr><td colspan="3">This is footer.</td></tr>
      </tfoot>
     <tbody>
    </tbody>
   </table>
  </body>
</html>

JSF column tag has some attribute for different purposes. These attributes are explained below:

  • rendered: This is an attribute of the column tag that is optional. This attribute can hold String typed value. This attribute value indicates that the component should be rendered during the rendering period.
  • binding: This attribute is also optional and take a String typed value. Specified value is linked with the backing bean through the attribute of the tag.
  • id: This attribute of the column tag is specified only for identification of the specific tag.