ArticlesTutorialsInterview Questions & AnswersCertificationsFree Books & Sample ChaptersTechnical Discussions  Your Account | Advertise with us | Feedback |
Few pages of this site are under construction and we are constantly trying to improve it. If you have any suggestions or ideas about how to improve the site, please Let us know.
Tomahawk DataTable

 t:dataScroller Tomahawk Tag Home t:div 

<t:dataTable>


Contents

  1. Introduction
  2. Tag Attributes
  3. Example

Introduction

The t:dataTable tag is an extension to the JSF data table tag but with added features. In particular, it introduces the following attributes: preserveDataModel, preserveSort, sortAscending and sortColumn. These attributes add performance and column sorting enhancements to the data table component.

Note :

  • DataScroller must be nested inside of an UIData component, or attribute "for" must be given so that corresponding uiData can be found.
  • The "row" attribute must be specified on the corresponding uiData.
  • The scope of pageIndexVar and pageCountVar is limited, and only direct children of DataScroller may see them.


Tag Attributes


AttributeDescription   Type    
align The align attribute is a standard HTML attribute that specifies this element's horizontal alignment.String
bgcolor The bgcolor attribute sets the background color for the table. This value can be the name or the hexadecimal value of the color.String
binding The value-binding expression linking this component tag to a backing bean property.String
border The border attribute sets the pixel width of the border to be drawn around the table.String
cellpadding The cellpadding attribute sets the width between the border of each cell and its contents.String
cellspacing The cellspacing attribute sets the width of the space between the outside and inside edges of the table as well as the space between cells.String
columnClasses The firstRowIndexVar attribute sets a name that can be used to reference the firstRowIndexVar parameter. The first row index represents the DISPLAYED UI data component's first row. The firstRowIndexVar parameter is set during request scope.String
datafldReserved for future use.String
dataformatasReserved for future use.String
datasrcReserved for future use.String
dirHTML: The direction of text display, either 'ltr' (left-to-right) or 'rtl' (right-to-left).String
enabledOnUserRole If user is in given role, this component will be rendered normally. If not, no hyperlink is rendered but all nested tags (=body) are rendered. String
firstThe index of the first row to be displayed, where 0 is the first row.String
footerClassThe CSS class to be applied to footer cells.String
forceIdIf true, this component will force the use of the specified id when rendering.String
forceIdIndex If false, this component will not append a '[n]' suffix (where 'n' is the row index) to components that are contained within a "list." This value will be true by default and the value will be ignored if the value of forceId is false (or not specified.) String
forceIdIndexFormula A formula that overrides the default row index in the construction of table's body components. Example : #{myRowVar.key} Warning, the EL should evaluate to a unique value for each row ! String
frame HTML: Controls what part of the frame that surrounds a table is visible. Values include: void, above, below, hsides, lhs, rhs, vsides, box, and border. String
headerClassThe CSS class to be applied to header cells.String
id The developer-assigned ID of this component. The ID must be unique within the scope of the tag's enclosing naming container (e.g. h:form or f:subview). This value must be a static value. String
langHTML: The base language of this document.String
newspaperColumns The number of columns to wrap the table over. Default: 1 String
newspaperOrientation The orientation of the newspaper columns in the newspaper table - "horizontal" or "vertical". Default: vertical String
onclickHTML: Script to be invoked when the element is clicked.String
ondblclickHTML: Script to be invoked when the element is double-clicked.String
onkeydownHTML: Script to be invoked when a key is pressed down over this element.String
onkeypressHTML: Script to be invoked when a key is pressed over this element.String
onkeyupHTML: Script to be invoked when a key is released over this element.String
onmousedownHTML: Script to be invoked when the pointing device is pressed over this element.String
onmousemoveHTML: Script to be invoked when the pointing device is moved while it is in this element.String
onmouseoutHTML: Script to be invoked when the pointing device is moves out of this element.String
onmouseoverHTML: Script to be invoked when the pointing device is moved into this element.String
onmouseupHTML: Script to be invoked when the pointing device is released over this element.String
preserveDataModel Indicates whether the state of the whole DataModel should be saved and restored. When set to false, the value-binding for the "value" attribute of this table is executed each time the page is rendered. When set to true, that value-binding is only executed when the component is first created, and the DataModel state is thereafter saved/restored automatically by the component. When column sorting is used for a table this property needs to be false so that the DataModel can be updated to reflect any changes in the sort criteria. Default: false String
preserveRowStates Indicates whether the state for each row should not be discarded before the datatable is rendered again. Setting this to true might be hepful if an input component inside the datatable has no valuebinding and the value entered in there should be displayed again. This will only work reliable if the datamodel of the datatable did not change either by sorting, removing or adding rows. Default: false String
preserveSort Indicates whether the state of the sortColumn and sortAscending attribute should be saved and restored and written back to the model during the update model phase. Default: true String
previousRowDataVar A parameter name, under which the previous RowData Object is set in request scope similar to the rowIndexVar and rowCountVar parameters. Mind that the value of this request scope attribute is null in the first row or when isRowAvailable returns false for the previous row. String
rendered A boolean value that indicates whether this component should be rendered. Default value: true. String
renderedIfEmpty Indicates whether this table should be rendered if the underlying DataModel is empty. You could as well use rendered="#{not empty bean.list}", but this one causes the getList method of your model bean beeing called up to five times per request, which is not optimal when the list is backed by a DB table. Using renderedIfEmpty="false" solves this problem, because the MyFaces extended HtmlDataTable automatically caches the DataModel and calles the model getter only once per request. Default: true String
rowClasses A comma separated list of CSS class names to apply to td elements in each row. String
rowCountVar A parameter name, under which the rowCount is set in request scope similar to the var parameter. String
rowGroupStyleCorresponds to the HTML style attribute for grouped rows.String
rowGroupStyleClassStyleClass for grouped rows.String
rowId The id to use for <tr> elements that are generated by the table. String
rowIndexVar A parameter name, under which the current rowIndex is set in request scope similar to the var parameter. String
rowOnClick Defines a JavaScript onclick event handler for each table row String
rowOnDblClick Defines a JavaScript ondblclick event handler for each table row String
rowOnKeyDown Defines a JavaScript onkeydown event handler for each table row String
rowOnKeyPress Defines a JavaScript onkeypress event handler for each table row String
rowOnKeyUp Defines a JavaScript onkeyup event handler for each table row String
rowOnMouseDown Defines a JavaScript onmpusedown event handler for each table row String
rowOnMouseMove Defines a JavaScript onmousemove event handler for each table row String
rowOnMouseOut Defines a JavaScript onmouseout event handler for each table row String
rowOnMouseOver Defines a JavaScript onmouseover event handler for each table row String
rowOnMouseUp Defines a JavaScript onmouseup event handler for each table row String
rowStyleCorresponds to the HTML style attribute for the row tr tag.String
rowStyleClassCorresponds to the HTML class attribute for the row tr tag.String
rowsThe number of rows to be displayed. Specify zero for all remaining rows in the table.String
rules HTML: Controls how rules are rendered between cells. Values include: none, groups, rows, cols, and all. String
sortAscending Value reference to a model property that gives the current sort direction. The target Boolean property is set to true when the selected sortColumn should be sorted in ascending order, and false otherwise. The method which is bound to the "value" attribute of this table (ie which provides the DataModel used) is expected to use this property to determine how to sort the DataModel's contents. String
sortColumn Value reference to a model property that gives the current sort column name. The target String property is set to the "columnName" of whichever column has been chosen to sort by, and the method which is bound to the "value" attribute of this table (ie which provides the DataModel used) is expected to use this property to determine how to sort the DataModel's contents. String
sortableString
sortedColumnVar A parameter name, under which the a boolean is set in request scope similar to the var parameter. TRUE for the column that is currently sorted, FALSE otherwise. String
styleHTML: CSS styling instructions.String
styleClassThe CSS class for this element. Corresponds to the HTML 'class' attribute.String
summary HTML: Provides a summary of the contents of the table, for accessibility purposes. String
titleHTML: An advisory title for this element. Often used by the user agent as a tooltip.String
valueAn EL expression that specifies the data model that backs this table. The value can be of any type. A value of type DataModel is used directly. Array-like parameters of type java.util.List, array of Object, java.sql.ResultSet, or javax.servlet.jsp.jstl.sql.Result are wrapped in a DataModel. Other values are wrapped in a DataModel as a single row.String
var*Defines the name of the request-scope variable that will hold the current row during iteration. This value must be a static value.String
varDetailToggler This variable has the boolean property "currentdetailExpanded" which is true if the current detail row is expanded and the action method "toggleDetail" which expand/collapse the current detail row. String
visibleOnUserRole If user is in given role, this component will be rendered normally. If not, nothing is rendered and the body of this tag will be skipped. String
width HTML: Specifies the desired width of the table, as a pixel length or a percentage of available space. String


Example



 As an example suppose we need to have list of car information to some of the entities in our application. First thing to do is to create the SimpleCar class with the id,type and color.


SimpleCar.java

package com.developersBook.tomahawk.examples.listExample;
import java.io.Serializable;
public class SimpleCar implements Serializable
{
private int id;
private String type;
private String color;
public SimpleCar(int id, String type, String color) {
super();
this.id = id;
this.type = type;
this.color = color;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}


DataScrollerList.java

package com.developersBook.tomahawk.examples.listExample;
import java.util.ArrayList;
import java.util.List;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import org.apache.myfaces.custom.datascroller.ScrollerActionEvent;
public class DataScrollerList
{
private Long rowCount = new Long(10);
public Long getRowCount() {
return rowCount;
}
public void setRowCount(Long rowCount) {
this.rowCount = rowCount;
}
private List carList = new ArrayList();
public DataScrollerList()
{
for (int i = 1; i < 995; i++)
{
carList.add(new SimpleCar(i, "Car Type " + i, "blue"));

  }
}
public List getList()
{
return carList;
}
public void scrollerAction(ActionEvent event)
{
ScrollerActionEvent scrollerEvent = (ScrollerActionEvent) event;
FacesContext.getCurrentInstance().getExternalContext().log(
"scrollerAction: facet: "
        + scrollerEvent.getScrollerfacet()
        + ", pageindex: "
        + scrollerEvent.getPageIndex());
  }

}

DataScrollerList.jsp

<f:view>
<h:form>
  <t:buffer into="#{buffer1}">
    <t:div><h:outputText value="BufferOne"/></t:div>
  </t:buffer>

  <t:buffer into="#{buffer2}">
    <t:div><h:outputText value="Buffer Two"/></t:div>
  </t:buffer>

  <h:outputText value="#{buffer2}" escape="false"/>
  <h:outputText value="#{buffer1}" escape="false"/>
  <h:outputText value="#{buffer2}" escape="false"/>

    <t:buffer into="#{table}">
    <t:dataTable id="data"
        styleClass="scrollerTable"
        headerClass="standardTable_Header"
        footerClass="standardTable_Header"
        rowClasses="standardTable_Row1,standardTable_Row2"

        var="car"
        value="#{scrollerList.list}"
        preserveDataModel="false"
        rows="10">
     <h:column>
       <f:facet name="header">
       </f:facet>
       <h:outputText value="#{car.id}" />
     </h:column>

     <h:column>
       <f:facet name="header">
         <h:outputText value="#{example_messages['label_cars']}" />
       </f:facet>
       <h:outputText value="#{car.type}" />
     </h:column>

    <h:column>
       <f:facet name="header">
         <h:outputText value="#{example_messages['label_color']}" />
       </f:facet>
       <h:outputText value="#{car.color}" />
     </h:column>

    </t:dataTable>
  </t:buffer>

  <t:buffer into="#{tableScroller}">
    <h:panelGrid columns="1" styleClass="scrollerTable2" columnClasses="standardTable_ColumnCentered" >
      <t:dataScroller id="scroll_1"
          for="data"
          fastStep="10"
          pageCountVar="pageCount"
          pageIndexVar="pageIndex"
          styleClass="scroller"
          paginator="true"
          paginatorMaxPages="9"
          paginatorTableClass="paginator"
          paginatorActiveColumnStyle="font-weight:bold;">
          <f:facet name="first" >
            <t:graphicImage url="images/arrow-first.gif" border="1" />
          </f:facet>
          <f:facet name="last">
            <t:graphicImage url="images/arrow-last.gif" border="1" />
          </f:facet>
          <f:facet name="previous">
            <t:graphicImage url="images/arrow-previous.gif" border="1" />
          </f:facet>
          <f:facet name="next">
            <t:graphicImage url="images/arrow-next.gif" border="1" />
          </f:facet>
          <f:facet name="fastforward">
            <t:graphicImage url="images/arrow-ff.gif" border="1" />
          </f:facet>
          <f:facet name="fastrewind">
            <t:graphicImage url="images/arrow-fr.gif" border="1" />
          </f:facet>
        </t:dataScroller>
        <t:dataScroller id="scroll_2"
            for="data"
            rowsCountVar="rowsCount"
            displayedRowsCountVar="displayedRowsCountVar"
            firstRowIndexVar="firstRowIndex"
            lastRowIndexVar="lastRowIndex"
            pageCountVar="pageCount"
            pageIndexVar="pageIndex">
            <h:outputFormat value="#{example_messages['dataScroller_pages']}" styleClass="standard" >
              <f:param value="#{rowsCount}" />
              <f:param value="#{displayedRowsCountVar}" />
              <f:param value="#{firstRowIndex}" />
              <f:param value="#{lastRowIndex}" />
              <f:param value="#{pageIndex}" />
              <f:param value="#{pageCount}" />
            </h:outputFormat>
        </t:dataScroller>
    </h:panelGrid>
  </t:buffer>

  <h:outputText value="#{tableScroller}" escape="false"/>
  <h:outputText value="#{table}" escape="false"/>
  <h:outputText value="#{tableScroller}" escape="false"/>

</h:form>
</f:view>


In the end, this is how it looks;




 t:dataList Tomahawk Tag Home t:dataTable 
Related Links

Tomahawk
t:aliasBean
t:aliasBeansScope
t:buffer
t:checkbox
t:collapsiblePanel
t:column
t:columns
t:commandButton
t:commandLink
t:commandNavigation
t:commandNavigation2
t:commandSortHeader
t:dataList
t:dataScroller
t:dataTable
t:div
t:document
t:documentBody
t:documentHead
t:dojoInitializer
t:graphicImage
t:headerLink
t:htmlTag
t:iconProvider
t:inputCalendar
t:inputDate
t:inputFileUpload
t:inputHidden
t:inputHtml
t:inputSecret
t:inputText
t:inputTextHelp
t:inputTextarea
t:jsValueChangeListener
t:jsValueSet
t:jscookMenu
t:message
t:messages
t:navigationMenuItem
t:navigationMenuItems
t:newspaperTable
t:outputLabel
t:outputText
t:panelGrid
t:panelGroup
t:panelLayout
t:panelNavigation
t:panelNavigation2
t:panelStack
t:panelTab
t:panelTabbedPane
t:popup
t:radio
t:saveState
t:schedule
t:selectBooleanCheckbox
t:selectItems
t:selectManyCheckbox
t:selectManyListbox
t:selectManyMenu
t:selectOneCountry
t:selectOneLanguage
t:selectOneListbox
t:selectOneMenu
t:selectOneRadio
t:stylesheet
t:swapImage
t:tabChangeListener
t:tree
t:tree2
t:treeCheckbox
t:treeColumn
t:treeSelectionListener
t:updateActionListener
t:validateCreditCard
t:validateEmail
t:validateEqual
t:validateRegExpr
Core Tags
f:actionListener
f:attribute
f:converter
f:convertDateTime
f:convertNumber
f:facet
f:loadBundle
f:param
f:selectitem
f:selectitems
f:subview
f:validateDoubleRange
f:validateLength
f:validateLongRange
f:validator
f:valueChangeListener
f:verbatim
f:view
HTML Tags
h:column
h:commandButton
h:commandLink
h:dataTable
h:form
h:graphicImage
h:inputHidden
h:inputSecret
h:inputText
h:inputTextarea
h:message
h:messages
h:outputFormat
h:outputLabel
h:outputLink
h:outputText
h:panelGrid
h:panelGroup
h:selectBooleanCheckbox
h:selectManyCheckbox
h:selectManyListbox
h:selectManyMenu
h:selectOneListbox
h:selectOneMenu
h:selectOneRadio
Tomahawk
t:aliasBean
t:aliasBeansScope
t:buffer
t:checkbox
t:collapsiblePanel
t:column
t:columns
t:commandButton
t:commandLink
t:commandNavigation
t:commandNavigation2
t:commandSortHeader
t:dataList
t:dataScroller
t:dataTable
t:div
t:document
t:documentBody
t:documentHead
t:dojoInitializer
t:graphicImage
t:headerLink
t:htmlTag
t:iconProvider
t:inputCalendar
t:inputDate
t:inputFileUpload
t:inputHidden
t:inputHtml
t:inputSecret
t:inputText
t:inputTextHelp
t:inputTextarea
t:jsValueChangeListener
t:jsValueSet
t:jscookMenu
t:message
t:messages
t:navigationMenuItem
t:navigationMenuItems
t:newspaperTable
t:outputLabel
t:outputText
t:panelGrid
t:panelGroup
t:panelLayout
t:panelNavigation
t:panelNavigation2
t:panelStack
t:panelTab
t:panelTabbedPane
t:popup
t:radio
t:saveState
t:schedule
t:selectBooleanCheckbox
t:selectItems
t:selectManyCheckbox
t:selectManyListbox
t:selectManyMenu
t:selectOneCountry
t:selectOneLanguage
t:selectOneListbox
t:selectOneMenu
t:selectOneRadio
t:stylesheet
t:swapImage
t:tabChangeListener
t:tree
t:tree2
t:treeCheckbox
t:treeColumn
t:treeSelectionListener
t:updateActionListener
t:validateCreditCard
t:validateEmail
t:validateEqual
t:validateRegExpr
Core Tags
f:actionListener
f:attribute
f:converter
f:convertDateTime
f:convertNumber
f:facet
f:loadBundle
f:param
f:selectitem
f:selectitems
f:subview
f:validateDoubleRange
f:validateLength
f:validateLongRange
f:validator
f:valueChangeListener
f:verbatim
f:view
HTML Tags
h:column
h:commandButton
h:commandLink
h:dataTable
h:form
h:graphicImage
h:inputHidden
h:inputSecret
h:inputText
h:inputTextarea
h:message
h:messages
h:outputFormat
h:outputLabel
h:outputLink
h:outputText
h:panelGrid
h:panelGroup
h:selectBooleanCheckbox
h:selectManyCheckbox
h:selectManyListbox
h:selectManyMenu
h:selectOneListbox
h:selectOneMenu
h:selectOneRadio
Tomahawk
t:aliasBean
t:aliasBeansScope
t:buffer
t:checkbox
t:collapsiblePanel
t:column
t:columns
t:commandButton
t:commandLink
t:commandNavigation
t:commandNavigation2
t:commandSortHeader
t:dataList
t:dataScroller
t:dataTable
t:div
t:document
t:documentBody
t:documentHead
t:dojoInitializer
t:graphicImage
t:headerLink
t:htmlTag
t:iconProvider
t:inputCalendar
t:inputDate
t:inputFileUpload
t:inputHidden
t:inputHtml
t:inputSecret
t:inputText
t:inputTextHelp
t:inputTextarea
t:jsValueChangeListener
t:jsValueSet
t:jscookMenu
t:message
t:messages
t:navigationMenuItem
t:navigationMenuItems
t:newspaperTable
t:outputLabel
t:outputText
t:panelGrid
t:panelGroup
t:panelLayout
t:panelNavigation
t:panelNavigation2
t:panelStack
t:panelTab
t:panelTabbedPane
t:popup
t:radio
t:saveState
t:schedule
t:selectBooleanCheckbox
t:selectItems
t:selectManyCheckbox
t:selectManyListbox
t:selectManyMenu
t:selectOneCountry
t:selectOneLanguage
t:selectOneListbox
t:selectOneMenu
t:selectOneRadio
t:stylesheet
t:swapImage
t:tabChangeListener
t:tree
t:tree2
t:treeCheckbox
t:treeColumn
t:treeSelectionListener
t:updateActionListener
t:validateCreditCard
t:validateEmail
t:validateEqual
t:validateRegExpr
Core Tags
f:actionListener
f:attribute
f:converter
f:convertDateTime
f:convertNumber
f:facet
f:loadBundle
f:param
f:selectitem
f:selectitems
f:subview
f:validateDoubleRange
f:validateLength
f:validateLongRange
f:validator
f:valueChangeListener
f:verbatim
f:view
HTML Tags
h:column
h:commandButton
h:commandLink
h:dataTable
h:form
h:graphicImage
h:inputHidden
h:inputSecret
h:inputText
h:inputTextarea
h:message
h:messages
h:outputFormat
h:outputLabel
h:outputLink
h:outputText
h:panelGrid
h:panelGroup
h:selectBooleanCheckbox
h:selectManyCheckbox
h:selectManyListbox
h:selectManyMenu
h:selectOneListbox
h:selectOneMenu
h:selectOneRadio

  ALSO SEE :

About Us | Our Mission | Terms of use | Author Terms |    Search        | Contact Us | Advertise With Us | Link to Us | Sitemap
Copyright © 2008 developersBOOK.COM. All rights reserved.