Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

Rani Subramani
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic