This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes JSF and the fly likes issue in displaying the body content(fetched dynamically) of the h:dataTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "issue in displaying the body content(fetched dynamically) of the h:dataTable" Watch "issue in displaying the body content(fetched dynamically) of the h:dataTable" New topic

issue in displaying the body content(fetched dynamically) of the h:dataTable

Rani Subramani

Joined: Jan 16, 2009
Posts: 7
Hi All,

I need to display a table for which no: of columns is fixed but the
values of those columns is
fetched dynamically and the filled.

I am using <h:dataTable> for displaying but, the problem is only the
header is displaying..
the body (ie the values fetched dynamically) are not displayed. I am
not able to figure out the reason for not displaying . Since, i have
set the bean and the DTO classess correctly..

Can anybody help me to solve this problem....

these are my pages


value="#{responseBean.responseDTO.resultData}" var="result"
cellpadding="5" cellspacing="7" border="10"
width="80" headerClass="header"

<f:facet name="header">
<hutputText value="Flights Name"

<hutputText value="#{result.flightNames}" styleClass="names" />


<f:facet name="header">
<hutputText value="Flights number"

<hutputText value="#{result.flightNumber}"

styleClass="names" />

Response Bean Class

public class ResponseBean {

private AvailableFlightsDetailsDTO responseDTO = null;
AvailableFlightsDetailsDTO availDetails = AvailableFlightsDetailsDTO

public ArrayList<ResultBean> searchResult() {
return availDetails.setResult();


public AvailableFlightsDetailsDTO getResponseDTO() {
return responseDTO;

public void setResponseDTO(AvailableFlightsDetailsDTO responseDTO) {
this.responseDTO = responseDTO;


This is that Response DTO class

public class AvailableFlightsDetailsDTO implements Serializable {

private List<SearchFlightsResponseDTO> flightDetails;
private ArrayList<ResultBean> resultData;

public static AvailableFlightsDetailsDTO S_INSTANCE = new

private AvailableFlightsDetailsDTO(){};

public static AvailableFlightsDetailsDTO getInstance(){
return S_INSTANCE;

public List<SearchFlightsResponseDTO> getFlightDetails() {
return flightDetails;

public void setFlightDetails(List<SearchFlightsResponseDTO>
flightDetails) {
this.flightDetails = flightDetails;

public ArrayList<ResultBean> getResultData() {
return resultData;

public void setResultData(ArrayList<ResultBean> resultData) {
this.resultData = resultData;


public ArrayList<ResultBean> setResult() {

ArrayList<ResultBean> list = new ArrayList<ResultBean>();
list = flightSearchList();
Iterator iterator = list.iterator();

while (iterator.hasNext()) {
Object obj =;

ResultBean result = new ResultBean();
result = (ResultBean) obj;

return list;

// Mock flightSearchList method

public ArrayList<ResultBean> flightSearchList(
) {

List<SearchFlightsResponseDTO> dtoList = new

resultData = new ArrayList<ResultBean>();
dtoList =this.getFlightDetails();
Iterator<SearchFlightsResponseDTO> dtoIterator = dtoList.iterator();

while (dtoIterator.hasNext()) {
SearchFlightsResponseDTO searchDTO =;
ResultBean bean=new ResultBean();


return resultData;


I actually set the dynamically fetched values in setFlightDetails. I
am able to set and get the values accordingly

config in faces-config

Thanks & Regards
sandeepy yadav

Joined: Feb 04, 2009
Posts: 6
I think you are going wrong way to display the data.If you are using DTO to display the Data.
You have to make follwing changes :-
1. Make a varible of DTO class in Main Bean Class.
3. Make an array of the DTO in Main Bean Class.
2. Make Getter /Setter of DTO & List DTO in Main Bean Class.
4. set all required value in DTO.
5. Add that instance in List<DTO> for each records
6. then display this list<DTO> in JSP page.

this will make your code simple & fast .

I agree. Here's the link:
subject: issue in displaying the body content(fetched dynamically) of the h:dataTable
jQuery in Action, 3rd edition