2013-07-29 147 views
2

我的問題是p:dialog未得到顯示。聽者被炒魷魚,沒有錯誤信息。我的要求是:當我選擇一行時,行的詳細信息必須在對話框中顯示。primefaces:對話框不顯示

請幫助我。提前致謝。

<h:form id="form"> 
    <p:dataTable id="cars" var="car" value="#{tableBean2.carsSmall}" paginator="true" 
     rows="10" rowKey="#{car.model}" selection="#{tableBean2.selectedCar}" 
     selectionMode="single"> 
     <p:ajax event="rowSelect" listener="#{tableBean2.onRowSelect}"  
      update=":form1:display :form1:growl" oncomplete="PF('carDialog').show()" /> 
     <p:ajax event="rowUnselect" listener="#{tableBean2.onRowUnselect}" 
      update=":form1:growl" /> 
     <f:facet name="header"> 
      Select a row to display a message 
     </f:facet> 
     <p:column headerText="Model"> 
      #{car.model} 
     </p:column> 
     <p:column headerText="Year"> 
      #{car.year} 
     </p:column> 
     <p:column headerText="Manufacturer" > 
      #{car.manufacturer} 
     </p:column> 
     <p:column headerText="Color"> 
      #{car.color} 
     </p:column> 
    </p:dataTable> 
</h:form> 

<h:form id="form1"> 
    <p:growl id="growl" showDetail="true"/> 
    <p:dialog id="dialog" header="Car Detail" widgetVar="carDialog" 
     resizable="false" position="center center" height="123" 
     width="456" appendToBody="true"> 
     <h:panelGrid id="display" columns="2" cellpadding="4"> 
      <h:outputText value="Model:" /> 
      <h:outputText value="#{tableBean2.selectedCar.model}" /> 
      <h:outputText value="Year:" /> 
      <h:outputText value="#{tableBean2.selectedCar.year}" /> 
      <h:outputText value="Manufacturer:" /> 
      <h:outputText value="#{tableBean2.selectedCar.manufacturer}" /> 
      <h:outputText value="Color:" /> 
      <h:outputText value="#{tableBean2.selectedCar.color}" /> 
     </h:panelGrid> 
    </p:dialog> 
</h:form> 
+0

開始:嘗試從對話框中刪除appendToBody =「true」' – Daniel

+0

我嘗試不加appendToBody。不工作 –

回答

3

我不能完全肯定PF的功能是什麼,但是當我跑在我結束你的代碼,改變

oncomplete="PF('carDialog').show()" 

oncomplete="carDialog.show()" 

<p:dialog>彈出。

+0

,這是因爲primefaces可以識別具有其ID的組件。在這種情況下,''的ID是'carDialog'。 'show'是隱式彈出的方法。 –

+0

@PrasadKharkar謝謝Prasad。我知道那麼多:)但是這是'PF'功能讓我失望。到目前爲止我沒有看到一個例子。還在尋找。 – Andy

+0

@PrasadKharkar展示使用它,但是當我下載源代碼時,我沒有看到它被使用(到目前爲止)。 – Andy