Jsf <;p:dataTable>;对话框中未显示单个选择
生成表后,在对话框上显示属性详细信息时遇到问题。将显示结果,但选定的行不会显示在对话框上。我从primefaces show case中接过了这个例子Jsf <;p:dataTable>;对话框中未显示单个选择,jsf,jsf-2,primefaces,Jsf,Jsf 2,Primefaces,生成表后,在对话框上显示属性详细信息时遇到问题。将显示结果,但选定的行不会显示在对话框上。我从primefaces show case中接过了这个例子 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="h
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title>TODO supply a title</title>
<h:outputStylesheet library="css" name="styles.css" />
</h:head>
<h:body>
Dear customer!
<li>#{userDataManager.displayHotelTypeChoice(userDataManager.hotelChoice)}
</li>
<li>#{userDataManager.displayPaxChoice(userDataManager.pax)}
</li>
<li>You have chosen to check in : #{userDataManager.displayCheckinDate(userDataManager.checkinDate)}
</li>
<li>You have chosen to check out : #{userDataManager.displayCheckoutDate(userDataManager.checkoutDate)}
</li>
<li>Total Days of Stay : #{userDataManager.countNightsBetween(userDataManager.checkinDate,userDataManager.checkoutDate)}
</li>
<li>Total Nights of Stay : #{userDataManager.nights}
</li>
<br>
</br>
<h:form id="form">
<p:dataTable id="hotels" var="room" value="#{propertyDataTable.searchByHotelType
(userDataManager.hotelChoice, userDataManager.pax)}"
rowKey="#{room.propertyID}"
selection="#{propertyDataTable.selectedProperty}"
selectionMode="single"
resizableColumns="true">
<f:facet name="header">
#{userDataManager.displayHotelTypeChoice(userDataManager.hotelChoice)}<br></br>
Please select only one choice
</f:facet>
<p:column headerText="Property ID" >
#{room.propertyID}
</p:column>
<p:column headerText="Accommodation" >
#{room.accommodation}
</p:column>
<p:column headerText="Pax" >
#{room.pax}
</p:column>
<p:column headerText="Stars" >
#{room.stars}
</p:column>
<p:column headerText="Type" >
#{room.type}
</p:column>
<f:facet name="footer">
In total there are #{propertyDataTable.listSize(propertyDataTable.
searchByHotelType(userDataManager.hotelChoice,
userDataManager.pax))} hotels.
<p:commandButton id="viewButton" value="View" icon="ui-icon-search"
update=":form:display" oncomplete="hotelDialog.show()">
</p:commandButton>
</f:facet>
</p:dataTable>
<p:dialog id="dialog" header="Hotel Detail" widgetVar="hotelDialog" resizable="false"
width="200" showEffect="clip" hideEffect="fold">
<h:panelGrid id="display" columns="2" cellpadding="4">
<f:facet name="header">
<!--<p:graphicImage value="/resources/images/#{propertyDataTable.selectedProperty.type}.jpg"/>-->
<p:graphicImage value="/resources/images/Grand.jpg"/>
</f:facet>
<h:outputText value="Accommodation:" />
<h:outputText value="#{propertyDataTable.selectedProperty.accommodation }" />
<h:outputText value="Feature:" />
<h:outputText value="#{propertyDataTable.selectedProperty.feature}" />
<h:outputText value="Stars:" />
<h:outputText value="#{propertyDataTable.selectedProperty.stars}" />
</h:panelGrid>
</p:dialog>
</h:form>
<br></br>
<br></br>
<h:commandButton value="Book"
action="#{navigationController.showPage()}" >
<f:param name="page" value="book" />
</h:commandButton>
<br></br>
<h:commandButton value="HOME"
action="#{navigationController.showPage()}" >
<f:param name="page" value="home" />
</h:commandButton>
</h:body>
</html>
提供头衔
亲爱的顾客!
#{userDataManager.displayHotelTypeChoice(userDataManager.hotelChoice)}
#{userDataManager.displayPaxChoice(userDataManager.pax)}
您已选择签入:#{userDataManager.displayCheckinDate(userDataManager.checkinDate)}
您已选择签出:#{userDataManager.displayCheckoutDate(userDataManager.checkoutDate)}
总停留天数:#{userDataManager.countNightsBetween(userDataManager.checkinDate,userDataManager.checkoutDate)}
住宿总夜数:#{userDataManager.Nights}
#{userDataManager.displayHotelTypeChoice(userDataManager.hotelChoice)}
请仅选择一个选项
#{room.propertyID}
#{房间.住宿}
#{room.pax}
#{room.stars}
#{room.type}
总共有#{propertyDataTable.listSize(propertyDataTable)。
searchByHotelType(userDataManager.hotelChoice,
userDataManager.pax)}酒店。
包数据表;
导入irms.entity.condition.Property;
导入irms.entity.condition.Room;
导入irms.session.accountment.PropertySession;
导入irms.session.accountment.ReservationSession;
导入java.io.Serializable;
导入java.util.ArrayList;
导入java.util.List;
导入javax.ejb.ejb;
导入javax.faces.bean.ManagedBean;
导入javax.faces.bean.ViewScoped;
/**
*
*@作者劳伦斯
*/
@ManagedBean(name=“propertyDataTable”)
@视域
公共类PropertyDataTable实现可序列化{
@EJB
私人预订会话预订会话;
@EJB
私人财产转让财产转让;
私有列表propertyList;
私人选择;
私有财产选择财产;
私有列表=新的ArrayList();
公共属性数据表(){
}
公共列表getAllRooms(){
返回reservationSession.getAllRooms();
}
公共列表searchByHotelType(字符串hotelType,整数pax){
this.propertyList=propertySession.searchByHotelType(hotelType,pax);
返回属性列表;
}
公共整数列表大小(列表){
返回list.size();
}
公共房间getRoom(字符串属性ID、整数roomID){
返回propertySession.findRoom(propertyID,roomID);
}
公共列表getRoomList(字符串属性ID){
返回propertySession.getRoomList(propertyID);
}
public ReservationSession getReservationSession(){
返回预订会话;
}
public void setReservationSession(ReservationSession ReservationSession){
this.reservationSession=reservationSession;
}
公共属性会话getPropertySession(){
返回属性session;
}
public void setPropertySession(PropertySession PropertySession){
this.propertySession=propertySession;
}
公共列表getPropertyList(){
返回属性列表;
}
公共void setPropertyList(列表propertyList){
this.propertyList=propertyList;
}
public int getChoice(){
回报选择;
}
公共void setChoice(int-choice){
这个。选择=选择;
}
公共属性getSelectedProperty(){
返回selectedProperty;
}
公共无效集合selectedProperty(Property selectedProperty){
this.selectedProperty=selectedProperty;
}
公共列表getList(){
退货清单;
}
公共无效集合列表(列表){
this.list=列表;
}
}
您必须在视图中添加ActionListener
按钮commandButton
更改xhtml
页面如下:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title>TODO supply a title</title>
<h:outputStylesheet library="css" name="styles.css" />
</h:head>
<h:body>
Dear customer!
<li>#{userDataManager.displayHotelTypeChoice(userDataManager.hotelChoice)}
</li>
<li>#{userDataManager.displayPaxChoice(userDataManager.pax)}
</li>
<li>You have chosen to check in : #{userDataManager.displayCheckinDate(userDataManager.checkinDate)}
</li>
<li>You have chosen to check out : #{userDataManager.displayCheckoutDate(userDataManager.checkoutDate)}
</li>
<li>Total Days of Stay : #{userDataManager.countNightsBetween(userDataManager.checkinDate,userDataManager.checkoutDate)}
</li>
<li>Total Nights of Stay : #{userDataManager.nights}
</li>
<br>
</br>
<h:form id="form">
<p:dataTable id="hotels" var="room" value="#{propertyDataTable.searchByHotelType
(userDataManager.hotelChoice, userDataManager.pax)}"
rowKey="#{room.propertyID}"
resizableColumns="true">
<f:facet name="header">
#{userDataManager.displayHotelTypeChoice(userDataManager.hotelChoice)}<br></br>
Please select only one choice
</f:facet>
<p:column headerText="Property ID" >
#{room.propertyID}
</p:column>
<p:column headerText="Accommodation" >
#{room.accommodation}
</p:column>
<p:column headerText="Pax" >
#{room.pax}
</p:column>
<p:column headerText="Stars" >
#{room.stars}
</p:column>
<p:column headerText="Type" >
#{room.type}
</p:column>
<f:facet name="footer">
In total there are #{propertyDataTable.listSize(propertyDataTable.
searchByHotelType(userDataManager.hotelChoice,
userDataManager.pax))} hotels.
<p:commandButton id="viewButton" value="View" icon="ui-icon-search"
update=":form:display" oncomplete="hotelDialog.show()">
<f:setPropertyActionListener value="#{room}" target="#{propertyDataTable.selectedProperty}" />
</p:commandButton>
</f:facet>
</p:dataTable>
<p:dialog id="dialog" header="Hotel Detail" widgetVar="hotelDialog" resizable="false"
width="200" showEffect="clip" hideEffect="fold">
<h:panelGrid id="display" columns="2" cellpadding="4">
<f:facet name="header">
<!--<p:graphicImage value="/resources/images/#{propertyDataTable.selectedProperty.type}.jpg"/>-->
<p:graphicImage value="/resources/images/Grand.jpg"/>
</f:facet>
<h:outputText value="Accommodation:" />
<h:outputText value="#{propertyDataTable.selectedProperty.accommodation }" />
<h:outputText value="Feature:" />
<h:outputText value="#{propertyDataTable.selectedProperty.feature}" />
<h:outputText value="Stars:" />
<h:outputText value="#{propertyDataTable.selectedProperty.stars}" />
</h:panelGrid>
</p:dialog>
</h:form>
<br></br>
<br></br>
<h:commandButton value="Book"
action="#{navigationController.showPage()}" >
<f:param name="page" value="book" />
</h:commandButton>
<br></br>
<h:commandButton value="HOME"
action="#{navigationController.showPage()}" >
<f:param name="page" value="home" />
</h:commandButton>
</h:body>
</html>
提供头衔
亲爱的顾客!
#{userDataManager.displayHotelTypeChoice(userDataManager.hotelChoice)}
#{userDataManager.displayPaxChoice(userDataManager.pax)}
您已选择签入:#{userDataManager.displayCheckinDate(userDataManager.checkinDate)}
您已选择签出:#{userDataManager.displayCheckoutDate(userDataManager.checkoutDate)}
总停留天数:#{userDataManager.countNightsBetween(userDataManager.checkinDate,userDataManager.checkoutDate)}
住宿总夜数:#{userDataManager.Nights}
#{userDataManager.displayHotelTypeChoice(userDataManager.hotelChoice)}
请选择