2012-08-16 74 views
2

我有一個嵌套的UI組件的問題,這可能是PrimeFaces和Mojara中的一個已知錯誤。然而我不知道我該如何解決它。Primefaces DataGrid - CommandLink不工作

我們與上傳者圖像畫廊,我希望能夠從DataGrid中刪除圖像,所以

XHTML:

<h:form enctype="multipart/form-data"> 

      <p:fileUpload fileUploadListener="#{pictureManagementBean.handleFileUpload}" 
        mode="advanced" 
        update="gallery messages" 
        auto="true"      
        allowTypes="/(\.|\/)(gif|jpe?g|png)$/" 
        /> 

      <p:growl id="messages" showDetail="true"/> 

      <p:dataGrid var="item" value="#{pictureManagementBean.pictures}" id="gallery"> 
       <p:panel header="#{item.pictureName}" style="text-align:center"> 
        <h:panelGrid columns="1" style="width:100%"> 

         <p:graphicImage value="#{item.thumbnailDir}" />        
         <h:outputText value="#{item.createdate.toString()}" />       
         <p:commandLink value="Delete" 
             action="#{pictureManagementBean.removePicture(item.idpicture)}" ajax="false"/> 

        </h:panelGrid> 
       </p:panel> 
      </p:dataGrid> 

     </h:form> 

基本上什麼都不在momment工作 - 在所有 - 是DataGrid中的commandLink Delete。其餘的都很好。

有沒有任何解決方法?我試過:列,ajax,沒有ajax ...沒有任何作品。我所能做的就是獲取DataGrid外部的按鈕。但那不是我想要的。

任何幫助欣賞。

[小東西:令人驚訝的是我已經在DataTable和Columns中使用了commandLink,沒有問題! ]

Primefaces 3.4RC1 from maven。 (3.3.1沒有工作要麼)

好了,所以我發現了一兩件事: <p:dataGrid>如果我用任何東西,但號碼:列其不工作。 但是然後視圖是可怕的...我應該只使用CSS來修復它?

+0

'PictureManagementBean'是視圖範圍,對吧? – BalusC 2012-08-16 10:53:45

+0

究竟是不是與commandLink一起工作?如果沒有任何反應,請嘗試明確更新'dataGrid'。 – Paranaix 2012-08-16 11:04:28

+3

快速查看文檔可以發現'p:panel'應該放在'p:column'中 – Paranaix 2012-08-16 11:08:32

回答

3

@Maple_shaft你是那麼對!

正確的代碼:

<p:dataGrid var="item" value="#{pictureManagementBean.pictures}" id="gallery"> 
       <p:column> 
        <p:panel header="#{item.pictureName}" style="text-align:center"> 
        <h:panelGrid columns="1" style="width:100%"> 

         <p:graphicImage value="#{item.thumbnailDir}" />        
         <h:outputText value="#{item.createdate.toString()}" />       
         <p:commandLink value="Delete" 
             action="#{pictureManagementBean.removePicture(item.idpicture)}" ajax="false"/> 

        </h:panelGrid> 
        </p:panel> 
       </p:column> 
      </p:dataGrid> 

所以只是簡單的列元素。我剛剛把它放錯了。非常感謝。

當然支持bean是@ViewScoped!