我是jsf Primefaces的初学者。我有primefaces数据表的问题。 当我在对话框组件中选择要查看的行时,不会显示任何内容。
<center>
<p:panel id="panel"
header="Gestion Points Services * Affichage *" >
<h:form id="myform">
<center>
<p:dataTable id="lesPS" var="ps"
value="#{listerPointSBean.listePointservice}"
rowKey="#{ps.idpointservice}"
selection="#{listerPointSBean.selectedPointservice}"
selectionMode="single"
emptyMessage="Aucuune Info dans la base"
paginator="true" rows="12"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15"
>
<f:facet name="header">
<p:outputPanel>
<h:outputText value="Search all fields:" />
<p:inputText id="globalFilter" style="width:150px" />
</p:outputPanel>
</f:facet>
<f:facet name="header">
Afficher les Points Services
</f:facet>
<p:ajax event="rowSelect" />
<p:column headerText="ID" filterBy="#{ps.idpointservice}"
sortBy="#{ps.idpointservice}">
<f:facet name="header">
<h:outputText value="ID" />
</f:facet>
<h:outputText value="#{ps.idpointservice}" />
</p:column>
<p:column headerText="Nom" filterBy="#{ps.nom}"
sortBy="#{ps.nom}">
<f:facet name="header">
<h:outputText value="nom" />
</f:facet>
<h:outputText value="#{ps.nom}" />
</p:column>
<p:column headerText="adresse" filterBy="#{ps.adresse}"
sortBy="#{ps.adresse}">
<f:facet name="header">
<h:outputText value="adresse" />
</f:facet>
<h:outputText value="#{ps.adresse}" />
</p:column>
<p:column headerText="email" filterBy="#{ps.email}"
sortBy="#{ps.email}">
<f:facet name="header">
<h:outputText value="email" />
</f:facet>
<h:outputText value="#{ps.email}" />
</p:column>
<p:column headerText="tel" filterBy="#{ps.telephone}"
sortBy="#{ps.telephone}">
<f:facet name="header">
<h:outputText value="tel" />
</f:facet>
<h:outputText value="#{ps.telephone}" />
</p:column>
<p:column headerText="latitude" filterBy="#{ps.latitude}"
sortBy="#{ps.latitude}">
<f:facet name="header">
<h:outputText value="latitude" />
</f:facet>
<h:outputText value="#{ps.latitude}" />
</p:column>
<p:column headerText="longitude" filterBy="#{ps.longitude}"
sortBy="#{ps.longitude}">
<f:facet name="header">
<h:outputText value="longitude" />
</f:facet>
<h:outputText value="#{ps.longitude}" />
</p:column>
<p:column headerText="Ville" filterBy="#{ps.ville}"
sortBy="#{ps.ville}">
<f:facet name="header">
<h:outputText value="ville" />
</f:facet>
<h:outputText value="#{ps.ville}" />
</p:column>
<p:column headerText="Gouv" filterBy="#{ps.gouvernat}"
sortBy="#{ps.gouvernat}">
<f:facet name="header">
<h:outputText value="gouv" />
</f:facet>
<h:outputText value="#{ps.gouvernat}" />
</p:column>
<p:column headerText="type" filterBy="#{ps.type}"
sortBy="#{ps.type}">
<f:facet name="header">
<h:outputText value="type" />
</f:facet>
<h:outputText value="#{ps.type}" />
</p:column>
<p:column>
<p:commandButton style="margin-right:10%" id="affichButton"
icon="ui-icon-search"
actionListener="#{listerPointSBean.test}" oncomplete="psDialog.show()" />
</p:column>
</p:dataTable>
<p:dialog id="psdialog" header="ps Detail" widgetVar="psDialog"
resizable="false" width="500" height="350" showEffect="clip"
hideEffect="fold">
<h:panelGrid id="display" columns="2" cellpadding="4">
<h:outputText value="nom:" />
<h:outputText
value="#{listerPointSBean.selectedPointservice.nom}" />
<h:outputText value="Adresse:" />
<h:outputText
value="#{listerPointSBean.selectedPointservice.adresse}" />
<h:outputText value="Email:" />
<h:outputText
value="#{listerPointSBean.selectedPointservice.email}" />
<h:outputText value="Tel:" />
<h:outputText
value="#{listerPointSBean.selectedPointservice.telephone}" />
<h:outputText value="latitude:" />
<h:outputText
value="#{listerPointSBean.selectedPointservice.latitude}" />
<h:outputText value="Longitude:" />
<h:outputText
value="#{listerPointSBean.selectedPointservice.longitude}" />
<h:outputText value="Ville:" />
<h:outputText
value="#{listerPointSBean.selectedPointservice.ville}" />
<h:outputText value="Gouv:" />
<h:outputText
value="#{listerPointSBean.selectedPointservice.gouvernat}" />
<h:outputText value="Zip:" />
<h:outputText
value="#{listerPointSBean.selectedPointservice.zip}" />
<h:outputText value="type:" />
<h:outputText
value="#{listerPointSBean.selectedPointservice.type}" />
</h:panelGrid>
</p:dialog>
</h:form>
</p:panel>
</center>
`
listerPointSBean托管bean如下:
@ManagedBean
@ViewScoped
public class ListerPointSBean implements Serializable {
private static final long serialVersionUID = 1L;
@EJB
PointserviceFacade bean;
List<String> Pointservices;
List<Pointservice> listePS;
private Pointservice selectedPointservice;
/**
* @return the Pointservices
*/
public List<String> getPointservices() {
listePS = bean.findAll();
return Pointservices;
}
/**
* @param Pointservices the Pointservices to set
*/
public void setPointservices(List<String> Pointservices) {
this.Pointservices = Pointservices;
}
/**
* @return the listePointservice
*/
public List<Pointservice> getListePointservice() {
listePS = bean.findAll();
return listePS;
}
/**
* @param listePointservice the listePointservice to set
*/
public void setListePointservice(List<Pointservice> listePointservice) {
this.listePS = listePointservice;
}
/**
* @return the selectedPointservice
*/
public Pointservice getSelectedPointservice() {
if(selectedPointservice ==null){
selectedPointservice=new Pointservice();
}
return selectedPointservice;
}
/**
* @param selectedPointservice the selectedPointservice to set
*/
public void setSelectedPointservice(Pointservice selectedPointservice) {
this.selectedPointservice = selectedPointservice;
}
public void delete() {
bean.remove(selectedPointservice);
}
public void editps(){
bean.edit(selectedPointservice);
}
我正在使用primefaces 3.5。 你能帮助我吗?感谢。
答案 0 :(得分:1)
你犯了一些错误。首先由@tiny评论“ 其中ListerPointSBean中的test()方法在actionListener中指定的 “
你的bean中的创建一个test()方法,你可以在其中设置你想要在对话框中显示的属性的值....
调用对话框的正确方法是
oncomplete="PF('psDialog').show()"
答案 1 :(得分:1)
在ajax rowSelect事件中,您需要在p:dialog中更新h:panelGrid。
<p:ajax event="rowSelect" update=":myform:display" oncomplete="psDialog.show()"/>