aspose file tools*
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 Java 8 in Action this week in the Java 8 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
Author

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

Rani Subramani
Greenhorn

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


search.jsp
--------------------


<h:dataTable
value="#{responseBean.responseDTO.resultData}" var="result"
cellpadding="5" cellspacing="7" border="10"
width="80" headerClass="header"
rowClasses="odd-row,even-row">


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


styleClass="headerNames"></hutputText>
</f:verbatim>
</f:facet>
<hutputText value="#{result.flightNames}" styleClass="names" />


</h:column>


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


styleClass="headerNames"></hutputText>
</f:verbatim>
</f:facet>
<hutputText value="#{result.flightNumber}"


styleClass="names" />
</h:column>
</h:dataTable>


Response Bean Class
----------------------------------------


public class ResponseBean {


private AvailableFlightsDetailsDTO responseDTO = null;
AvailableFlightsDetailsDTO availDetails = AvailableFlightsDetailsDTO
.getInstance();


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
AvailableFlightsDetailsDTO();


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() {
flightSearchList();
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 = iterator.next();


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


}
return list;
}


// Mock flightSearchList method


public ArrayList<ResultBean> flightSearchList(
) {


List<SearchFlightsResponseDTO> dtoList = new


ArrayList<SearchFlightsResponseDTO>();
resultData = new ArrayList<ResultBean>();
dtoList =this.getFlightDetails();
//System.out.println(""+dtoList);
Iterator<SearchFlightsResponseDTO> dtoIterator = dtoList.iterator();


while (dtoIterator.hasNext()) {
SearchFlightsResponseDTO searchDTO = dtoIterator.next();
ResultBean bean=new ResultBean();
bean.setArrivalLocationCode(searchDTO.getArrivalLocationCode());
bean.setDepLocationCode(searchDTO.getDepLocationCode());
bean.setFlightNames(searchDTO.getFlightName());
bean.setFlightNumber(searchDTO.getFlightNumber());
resultData.add(bean);


}


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
----------------------------------------------
<managed-bean>
<managed-bean-name>responseBean</managed-bean-name>
<managed-bean-class>
com.mindtree.tnt.flightsearch.bean.ResponseBean
</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>





Thanks & Regards
Rani
sandeepy yadav
Greenhorn

Joined: Feb 04, 2009
Posts: 6
hi,
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 .

Thanks
Sawan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: issue in displaying the body content(fetched dynamically) of the h:dataTable
 
Similar Threads
One-To-Many Child Objects Not Rendering
Using of nested Datatables
Input row select on data table does not get called
Which Package to Import to Use FacesContext's getRequestMap()?
problem with datatable binding attribute