3

I have this piece of code that upload files:

<p:dialog id="addFileDialog" 
              header="#{text['tasksbacking.attach.addFile']}" 
              widgetVar="addfile"
              height="500"
              width="500"
              closeOnEscape="true" 
              resizable="false" 
              draggable="false"                                            
              fitViewport="true"
              modal="true" 
              appendTo="@(body)">
 <h:form enctype="multipart/form-data">
       <p:fileUpload  fileUploadListener="#{attachmentsComponent.handleFileUpload}" 
                      mode="advanced" 
                      multiple="true" 
                      dragDropSupport="true"
                      allowTypes="/(\.|\/)(gif|jpe?g|png|pdf|doc|docx|txt)$/"
                      label="#{text['tasksbacking.addFile.choose']}"
                      uploadLabel="#{text['tasksbacking.addFile.upload']}"
                      cancelLabel="#{text['tasksbacking.addFile.cancel']}"/>
  </h:form>
  <p:ajax event="close" 
          update=":#{cc.clientId}:addFileDialog,:#{cc.clientId}:formAttachForm:attachTree,:#{cc.clientId}:formAttachForm:msgTreeAction,:#{cc.clientId}:attachContainer" listener="#{attachmentsComponent.onCloseUpload}"/>
</p:dialog>

With this code, I can upload files when I close the dialog. But I cannot execute another AJAX action, without refreshing the page. The other actions execute well when I don't upload files as the first action.

What could be the problem to execute the forward actions without refreshing the page? The enctype of the form could be the problem?

Tiny
  • 27,221
  • 105
  • 339
  • 599
tech4
  • 541
  • 2
  • 14
  • 37

1 Answers1

3

I had the same problem with enctype="multipart/form-data" form and i see this question:

And after i use this answers:

Finally, it worked!

Basically the re-render/customization of the component p:fileUpload works fine and this is one primefaces bug.

Community
  • 1
  • 1
Marin
  • 1,010
  • 1
  • 10
  • 37