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 Buffer

  t:aliasBeansScope Tomahawk Tag Home t:checkbox 

<t:buffer>


Contents

  1. Introduction
  2. Tag Attributes
  3. Example

Introduction

The t:buffer tag allows you to render parts of the page into a buffer to be displayed later. This can be useful for rendering if one component cannot be rendered before another component it is dependent on.

One use of t:buffer is the dataScroller. If you display a table with t:dataTable, you can't have dataScroller BEFORE the table, as it can't find the not yet rendered table.
So, the solution is that you first render the table to a buffer, then you render the dataScroller, and then you render the buffer's content.
That way, the dataScroller will appear before the table even though it was rendered after it.


Note  :The generated links within the buffer are only supported with the MyFaces implementation because of the lack of standard dummy form parameters support.

Tag Attributes


AttributeDescription   Type    
id The unique identifier value for this component. The value must be unique within the closest naming container (e.g.,h:form or f:subview).This value must be a static value.String
into (required) The into attribute creates a jsp object that the buffered content will be stored.String
rendered A value-binding expression that evaluates to a Boolean condition indicating if this component should be rendered.String


Example


One use of t:buffer is the dataScroller. If you display a table with t:dataTable, you can't have dataScroller BEFORE the table, as it can't find the not yet rendered table.
So, the solution is that you first render the table to a buffer, then you render the dataScroller, and then you render the buffer's content.
That way, the dataScroller will appear before the table even though it was rendered after it.


 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:aliasBeansScope Tomahawk Tag Home t:checkbox 
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

  ALSO SEE :

About Us | Our Mission | Terms of use | Author Terms |    Search        | Contact Us | Advertise With Us | Link to Us | Sitemap
Copyright © 2016 developersbook.com. All rights reserved.