2017-09-13 2 views
2

Ich versuche, eine Datei mit PrimeFaces p hochladen: Dateiupload innen p: Dialog, aber es funktioniert nichtp: Fileupload nicht innerhalb p arbeiten: Dialog

<h:form id="form3"> 
     <p:commandLink value="upload" oncomplete="PF('Dialog').show()" />    
     <p:dialog widgetVar="submitDialog" modal="true" > 
       <h:form id="form" enctype="multipart/form-data" > 
        <h:panelGrid id="submitPanelGrid" columns="2" > 
         <p:fileUpload id="upload" value="#{bean.file}" mode="simple" sizeLimit="100000" /> 
         <p:commandButton id="btn3" action="#{bean.submit()}" icon="ui-icon-circle-check" ajax="false" /> 
        </h:panelGrid> 
       </p:panel> 
       </h:form> 
     </p:dialog> 
</h:form> 

ich diese Ausnahme immer kurz nachdem ich auf den Link klicken:

org.apache.tomcat.util.http.fileupload.FileUploadBase $ InvalidContentTypeException: die Anforderung nicht eine multipart/form-data oder multipart/mixed Strom enthält,
Content-Type-Header ist application/x-www-form-urlencoded;

Aber außerhalb <p:dialog> funktioniert es ganz gut.

+0

Haben Sie versucht, das Multipart im Formular anzugeben? ex:

+0

ja ich habe versucht und es hat nicht funktioniert – Alfonso

+1

Verschachtelte Formen sind nicht erlaubt in HTML (und JSF) – Kukeltje

Antwort

1

Zunächst wird eine Form innerhalb eines anderen nicht in HTML erlaubt ist, müssen Sie den Dialog aus der Hauptform zu trennen, und für die Ausnahme Sie bekommen Sie enctype="multipart/form-data" zu Ihrem Dialogform hinzufügen:

<h:form id="form3"> 
     <p:commandLink value="upload" oncomplete="PF('Dialog').show()" />  
    </h:form>  

    <p:dialog widgetVar="submitDialog" modal="true" > 
      <h:form id="form" enctype="multipart/form-data" > 
       <h:panelGrid id="submitPanelGrid" columns="2" > 
        <p:fileUpload id="upload" value="#{bean.file}" mode="simple" sizeLimit="100000" /> 
        <p:commandButton id="btn3" action="#{bean.submit()}" icon="ui-icon-circle-check" ajax="false" /> 
       </h:panelGrid> 
      </p:panel> 
      </h:form> 
    </p:dialog> 
+0

Großartig, danke, es hilft wirklich – Alfonso

Verwandte Themen