2014-01-20 69 views
2

我是jsf Primefaces的初學者。我有一個primefaces數據表的問題。 當我選擇一行以在對話框組件中查看它時,不會顯示任何內容。如何使用jsf 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

您是否嘗試過使用Firebug/other進行檢查,或者設置p:dialog AppendToBody = true? – Pellizon

+0

'

'標籤很久以前就被棄用了。避免使用它。改用CSS。 – Tiny

+1

在''的'actionListener'中指定的'ListerPointSBean'中的'test()'方法? – Tiny

回答

0

你已經犯了一些錯誤。首先作爲評論說@tiny「 如考慮的 ActionListener的規定在ListerPointSBean測試()方法」

在bean讓你設置屬性值進行測試()方法要在對話框中顯示....

叫出也是正確的做法是

oncomplete="PF('psDialog').show()" 
1

在您需要更新您的H AJAX rowSelect事件:內部p panelGrid中:對話框。

<p:ajax event="rowSelect" update=":myform:display" oncomplete="psDialog.show()"/> 
+0

這就是我需要的「update =」:myform:display「。謝謝:) – user3215299

相關問題