Tomahawk columns tag

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;
import java.util.*;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
public class ColumnBean{
private DataModel columns;
private Map valueMap = new HashMap();
Object key;
public DataModel getColumnDataModel(){
String[] cols = new String[] {"Column 1", "Column 2", "Column 3"};
columns = new ListDataModel(new ArrayList(Arrays.asList(cols)));
return columns;
}
public String getColumnValue(){
String randomNo = String.valueOf((int) (Math.random()*1000));
valueMap.put(key, randomNo);
return (String) valueMap.get(key);
}
}
|
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 :
- id : This is the value which is used to
uniquely identify the component within the closest container like form or
subview. The main thing to remember is that its value must be a static
value.
- binding : This attribute is used to specify
the property of the backing bean with which this component instance is to be
bound.
- rendered : Its default value is true.
If this attribute is set to true then this component is presented in
the page to the user. If false, then this component is not rendered.
- dir : It is used to set the direction of the
text to be displayed. It can take two values LTR(left to right) and RTL
(right to left).
- lang : It is used to set the base language of
the component when displayed.
- style : It is used to set the CSS style
definition for the component.
- title : It is the standard html attribute. It
is used to set the tooltip text for this component.
- styleClass : It is used to set the CSS class
for the component. It is same as html class attribute.
- onclick : Script to be invoked when the
element is clicked.
- ondblclick : It is used for Java Script code
to be invoked when the element is double-clicked.
- onmousedown : It is used for Java Script code
to be invoked when the pointing device is pressed over this element.
- onmouseup : It is used for Java Script code
to be invoked when the pointing device is released over this element.
- onmouseover : It is used for Java Script code
to be invoked when the pointing device is moved into this element.
- onmousemove : It is used for Java Script code
to be invoked when the pointing device is moved while it is in this element.
- onmouseout : It is used for Java Script code
to be invoked when the pointing device is moved out of this element.
- onkeypress : It is used for Java Script code
to be invoked when a key is pressed over this element.
- onkeydown : It is used for Java Script code
to be invoked when a key is pressed down over this element.
- onkeyup : It is used for Java Script code to
be invoked when a key is released over this element.
- value : This attribute is used to set the
current value of the component.
- var : This attribute can be used to access the current column in the iteration.
- headerdir : This attribute is used to
define the direction of the header text. It can take two values "ltr"
and "rtl".
- headerlang : It is used to set the language
of the header of this tag.
- headerstyle : It is used to set the CSS style
definition for header of this tag.
- headertitle :
It
is used to set the tooltip text for header of this tag.
- headercolspan : This attribute is used
to apply one header for more than one column.
- headerstyleClass : It is used to set the CSS class
for the header of the tag.
- headeronclick : It is used for Java Script code
to be invoked when the header of the tag is clicked.
- headerondblclick : It is used for Java Script code
to be invoked when the header of the tag is double-clicked.
- headeronmousedown : It is used for Java Script code
to be invoked when the pointing device is pressed over the header.
- headeronmouseup : It is used for Java Script code
to be invoked when the pointing device is released over the header.
- headeronmouseover : It is used for Java Script code
to be invoked when the pointing device is moved into the header.
- headeronmousemove : It is used for Java Script code
to be invoked when the pointing device is moved while it is in the header.
- headeronmouseout : It is used for Java Script code
to be invoked when the pointing device is moves out of the header.
- headeronkeypress : It is used for Java Script code
to be invoked when a key is pressed over the header.
- headeronkeydown :
It is used for Java Script code
to be invoked when a key is pressed down over the header.
- headeronkeyup :
It is used for Java Script code to
be invoked when a key is released over the header.
- footerdir : This
attribute is used to define the direction of the footer text. It can take
two values "ltr" and "rtl".
- footerlang : It is used to set the language
of the footer of this tag.
- footerstyle : It is used to set the CSS style
definition for footer of this tag.
- footertitle : It
is used to set the tooltip text for footer of this tag.
- footercolspan : This
attribute is used to apply one footer for more than one column.
- footerstyleClass : It is used to set the CSS class
for the footer of the tag.
- footeronclick : It is used for Java Script code
to be invoked when the footer of the tag is clicked.
- footerondblclick : It is used for Java Script code
to be invoked when the footer of the tag is double-clicked.
- footeronmousedown : It is used for Java Script code
to be invoked when the pointing device is pressed over the footer.
- footeronmouseup : It is used for Java Script code
to be invoked when the pointing device is released over the footer.
- footeronmouseover : It is used for Java Script code
to be invoked when the pointing device is moved into the footer.
- footeronmousemove : It is used for Java Script code
to be invoked when the pointing device is moved while it is in the footer.
- footeronmouseout : It is used for Java Script code
to be invoked when the pointing device is moved out of the footer.
- footeronkeypress : It is used for Java Script code
to be invoked when a key is pressed over the footer.
- footeronkeydown : It is used for Java Script code
to be invoked when a key is pressed down over the footer.
- footeronkeyup : It is used for Java Script code to
be invoked when a key is released over the footer.
- width : This is used to set the width of this
component.
- colspan : This attribute specifies the
colspan attribute for the cell.
- groupBy : This attribute is used to group by data in this column.
- defaultSorted : This is the boolean
attribute. When this attribute is set to true for a particular column then
that column will be rendered already sorted but this attribute will be
effective only when "sorted" attribute is set to
true.
- sortable : This is a boolean attribute. When
this attribute is set to true only then the column sorting gets effective.
- sortPropertyName : This attribute specifies
the name of the property according to which the sorting of the column is
performed.

|