This tag is used to allow dynamic number of columns for a dataTable. This creates columns iterating through datamodel. Its "value" attribute takes all the values which its wrapper datatable's "value" attribute can take. In other words "value" attribute can accept DataModel, List, Array. "Var" attribute is used to access the current column in the iteration. Using this columns tag we don't need to write many column tags. This iterates over the datamodel and produces columns for the datatable. It provides many attributes for header and footer of the column which can be used to provide new functionality in the columns. Its sorting capability is really very good. We can sort the columns by clicking the column header if the sorting attribute is set to true. Default sorting can also be applied to get the column sorted automatically when the page is rendered and sorting according to the property can also be applied.
Code Description :
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<html>
<body>
<f:view>
<h:form>
<t:dataTable id="data" var="column"
value="#{ColumnBean.columnDataModel}"
preserveDataModel="false">
<t:columns value="#{ColumnBean.columnDataModel}" var="column">
<f:facet name="header">
<h:outputText value="#{column} " />
</f:facet>
<h:outputText value="#{ColumnBean.columnValue}" />
</t:columns>
</t:dataTable>
</h:form>
</f:view>
</body>
</html>
|
Backing Bean (ColumnBean.java) :
package net.roseindia.web.ui;
|
Rendered Output :

Html Source Code :
<html>
<body>
<form id="_idJsp0" name="_idJsp0" method="post"
action="/tomahawk_tags/pages/columns.jsf;
jsessionid=8A5A0129087A6D95E2936D8C3A750687"
enctype="application/x-www-form-urlencoded">
<table id="_idJsp0:data">
<thead>
<tr>
<th>Column 1 </th>
<th>Column 2 </th>
<th>Column 3 </th>
</tr>
</thead>
<tbody id="_idJsp0:data:tbody_element">
<tr>
<td>44</td><td>887</td>
<td>639</td>
</tr>
<tr>
<td>934</td>
<td>599</td>
<td>338</td>
</tr>
<tr>
<td>598</td>
<td>904</td>
<td>273</td>
</tr></tbody>
</table>
<input type="hidden" name="_idJsp0_SUBMIT" value="1" />
<input type="hidden" name="javax.faces.ViewState"
id="javax.faces.ViewState" value="rO0ABXVyABNbTGphdmEub
GFuZy5PYmplY3Q7kM5YnxBzKWwCAAB4cAAAAAN0AAExcHQAEi9wYWdl
cy9jb2x1bW5zLmpzcA==" /></form>
<!-- MYFACES JAVASCRIPT -->
</body>
</html>
|
This tag contains attributes given below :
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Tomahawk columns tag View All Comments
Post your Comment