You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Marcus Bond <ma...@hotmail.com> on 2006/11/24 19:24:27 UTC

RE: Tomahawk Extended datatable problem, running on Tomcat 4.1

Your dataTable needs a value attribute which calls a method in a backing 
bean that returns one of the supported collections holding 'rows' of data 
(in this case a list of ObjectWithData instances). The dataTable will 
iterate over all items in the list and reference the current row with the 
var attribute (in this case the var is called eachRow)..

You then specify which of the parameters from the object referenced by 
'eachRow' you wish to display in each column of the table.

<t:dataTable id="myTable"
             value="#{myBean.listOfObjectsWithData}"
             var="eachRow"
             headerClass="jsfTableHeading"
             rowClasses="jsfTableRow1, jsfTableRow2">

   <h:column>
      <h:outputText value="#{eachRow.firstParam}" />
      <h:outputText value=" " />
      <h:outputText value="#{eachRow.secondParam}" />
   </h:column>

   <h:column>
      <h:outputText value="#{{eachRow.thirdParam}" />
   </h:column>

   <h:column>
      <h:outputText value="#{{eachRow.fourthParam}" />
   </h:column>
</t:dataTable>


Your backing bean (as I'm using a list here) would have the following 
method:

public List<ObjectWithData> getListOfObjectsWithData() {
   List<ObjectWithData> aList;
   // Populate list from underlying data source etc...
   return aList;
}


The item referenced by the var attribute value (eachRow) in the h:dataTable 
tag will then iterate over the List of objects, for instance:

public class ObjectWithData {
   private String firstParam;
   private String secondParam;
   private String thirdParam;
   private String fourthParam;

   // Getters and setters...

}

So basically you need to provide the dataTable tag with a method that 
returns a supported collection of some type.

Hope this helps,
Marcus

>From: "Tran, Paul" <Pa...@emergis.com>
>Reply-To: "MyFaces Discussion" <us...@myfaces.apache.org>
>To: <us...@myfaces.apache.org>
>Subject: Tomahawk Extended datatable problem, running on Tomcat 4.1 Date: 
>Thu, 23 Nov 2006 16:55:08 -0500
>
>Hi,
>
>
>
>I am currently trying to use some of your components and I have success
>with most of them, except for the extended datatable. The code that I
>wrote is really simple and I can't locate what is wrong. Here is a
>sample of my code calling the datatable :
>
>
>
><t:dataTable id="data" var="searchResult" border="1">
>          <h:column>
>                <h:outputText value="test" />
>         </h:column>
></t:dataTable>
>

_________________________________________________________________
Be the first to hear what's new at MSN - sign up to our free newsletters! 
http://www.msn.co.uk/newsletters