-
1. Re: how to populate data in datatable
sivaprasad9394 Jul 20, 2012 2:32 AM (in response to wingman)Hi,
You can do it like below,
Home.java
public List<Sample> getListSample() {
listSample=new ArrayList<Sample>();
Sample one1=new Sample();
one1.setName1("Jai");
one1.setName2("Cha");
one1.setName3("27");
listSample.add(one1);
Sample one2=new Sample();
one2.setName1("M");
one2.setName2("Gra");
one2.setName3("Eng");
listSample.add(one2);
System.out.println("Size :"+listSample.size());
return listSample;
}
list.xhtml
<rich:dataTable value="#{projectTasksHome.listSample}" var="test">
<rich:column>
<f:facet name="header">
First Name
</f:facet>
<h:outputText value="#{test.name1}" />
</rich:column>
<rich:column>
<f:facet name="header">
Last Name
</f:facet>
<h:outputText value="#{test.name2}" />
</rich:column>
<rich:column>
<f:facet name="header">
Country
</f:facet>
<h:outputText value="#{test.name3}" />
</rich:column>
</rich:dataTable>
Thanks,
Siva
-
2. Re: how to populate data in datatable
wingman Jul 20, 2012 1:26 PM (in response to sivaprasad9394)Hi
Thansk for the response, But the requirement is like..
Let say i have one record in my list (one object with 6 fields) and i want to display it in multiple rows as shown below but with above example it displays in single row
First Name: John Last Name: Williams Age:36 Gender:M Education:Graduate Address:England -
3. Re: how to populate data in datatable
ibstmt Jul 20, 2012 3:02 PM (in response to wingman)1 of 1 people found this helpfulWhat about using DataGrid?
3.0: http://livedemo.exadel.com/richfaces-demo/richfaces/dataGrid.jsf?c=dataGrid&tab=usage
4.0: http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=dataGrid&skin=blueSky
-
4. Re: how to populate data in datatable
wingman Jul 21, 2012 12:08 PM (in response to ibstmt)Thanks ibstmt,
thanks for your reply,
will it possible colspan in dataGrid,, tried but no luck, sorry i m new bee to richfaces, please suggest.
-
5. Re: how to populate data in datatable
vi_mahe_ka1 Jul 22, 2012 3:58 AM (in response to wingman)You can slightly modify the above example to achieve this,
use table instead of rich:column inside the <rich:dataTablei.e
<rich:dataTable value="#{M.B.list}" var=var >
<table><tr><td>FirstName</td><td>#{var.firstName}</td>><td>LastName</td><td>#{var.lastName}</td>
<tr><td>Age</td><td>#{var.age}</td>><td>Gender</td><td>#{var.gender}</td>
<tr><td>Education</td><td>#{var.education}</td>><td>Address</td><td>#{var.address}</td>
-
6. Re: how to populate data in datatable
wingman Jul 22, 2012 2:02 PM (in response to vi_mahe_ka1)Thanks for the reply Mahesh,
I already tried using table inside dataTable but it desn't work here is my code,
<rich:dataTable value="#{cars.listSample}" var="car" cellpadding="0" cellspacing="0" width="700" border="1">
<table border="1" >
<tr>
<td>FirstName</td>
<td><h:outputText value="#{car.name1}" /></td>
<td>LastName</td>
<td><h:outputText value="#{car.name2}" /></td>
</tr>
<tr>
<td>Age</td>
<td><h:outputText value="#{car.name1}" /></td>
<td>Gender</td>
<td><h:outputText value="#{car.name1}" /></td>
</tr>
<tr>
<td>Education</td>
<td><h:outputText value="#{car.name1}" /></td>
<td>Address</td>
<td><h:outputText value="#{car.name1}" /></td>
</tr>
</table>
</rich:dataTable>
-
7. Re: how to populate data in datatable
vi_mahe_ka1 Jul 23, 2012 2:41 AM (in response to wingman)Hi,
The missing part in the above code is <rich:column>
try below code which works fine for me
<rich:dataTable value="#{testData.list}" var="result">
<rich:column>
<table border="1">
<tr>
<td>First Name</td>
<td><h:outputLabel value="#{result.createdBy}" /></td>
<td>Age</td>
<td>#{result.updatedBy}</td>
</tr>
<tr>
<td>Age</td>
<td>#{result.updatedBy}</td>
<td>Age</td>
<td>#{result.updatedBy}</td>
</tr>
<tr>
<td>Age</td>
<td>#{result.updatedBy}</td>
<td>Age</td>
<td>#{result.updatedBy}</td>
</tr>
</table>
</rich:column>
</rich:dataTable> -
8. Re: how to populate data in datatable
sivaprasad9394 Jul 23, 2012 4:35 AM (in response to wingman)Once you run the above code it show like below,
First Name: John Last Name: Williams Age:36 Gender:M Education:Graduate Address:England First Name: Serena Last Name: Williams Age:32 Gender:F Education:UG Address:Oakland Herw Please add the String First Name in the back end,like
one1.setName1("First Name :Jai");
OR
Based on the reRender attribute and rendered attribute you can add the label and display the text.
Thanks,
Siva