2014-09-26 103 views
1

我有這樣的事情:如何防止燒成號碼:filepload

<h:form id="form"> 

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

    <p:dataGrid var="car" 
       value="#{jSFmanageBean.cars}" 
       id="gallery" > 
     <p:panel header="#{car.id}" 
       style="text-align:center" 
       id="testSomething"> 
      <p:graphicImage alt="ERROR2" 
          value="#{jSFmanageBean.image2}" 
          width="250"> 
       <f:param name="id" value="#{car.id}" /> 
      </p:graphicImage> 
     </p:panel> 
    </p:dataGrid> 

    <p:commandLink update=":form:carDetail" 
        oncomplete="PF('carDialog').show()" 
        title="View Detail"> 
     <h:outputText styleClass="ui-icon ui-icon-search" 
         style="margin:0 auto;" /> 
     <f:setPropertyActionListener value="#{car}" 
            target="#{jSFmanageBean.selectedCar}" /> 
    </p:commandLink> 

    <p:dialog header="Car Info" 
       widgetVar="carDialog" 
       modal="true" 
       showEffect="fade" 
       hideEffect="fade" 
       resizable="false"> 
     <p:outputPanel id="carDetail" 
         style="text-align:center;"> 
      <p:panelGrid columns="2" 
          rendered="#{not empty jSFmanageBean.selectedCar}" 
          columnClasses="label,value"> 

       <h:outputText value="Id:" /> 
       <h:outputText value="#{jSFmanageBean.selectedCar.id}" /> 

      </p:panelGrid> 
     </p:outputPanel> 
    </p:dialog> 
</h:form> 

問題是,當我嘗試使用「P:commandLink」的「P:文件上傳」組件被觸發(或類似的東西那),我有錯誤。

Warning: javax.servlet.ServletException: The request content-type is not a multipart/form-data 
javax.faces.FacesException: javax.servlet.ServletException: The request content-type is not a multipart/form-data 
at org.primefaces.component.fileupload.NativeFileUploadDecoder.decode(NativeFileUploadDecoder.java:44) 
at org.primefaces.component.fileupload.FileUploadRenderer.decode(FileUploadRenderer.java:44) 
. 
. 
. 
Caused by: javax.servlet.ServletException: The request content-type is not a multipart/form-data 
. 
. 

如何防止觸發FileUpload當我在同一個窗體中使用其他ajax的東西?

回答

1

當您單擊p:commandLink時,您正在處理整個表格,因爲默認情況下爲提交類型。不知道你太多的目的,一個簡單的方法來防止將被添加process="@this"p:commandLink避免處理表格的其餘部分(如果要處理更多的事情,你可以將它們添加):

<p:commandLink update=":form:carDetail" process="@this" 
       oncomplete="PF('carDialog').show()" 
       title="View Detail"> 
+0

OK謝謝,這就是工作。 – DarkMisha 2014-09-30 08:35:08

+0

歡迎:) – mrganser 2014-09-30 08:38:32