Finish uploading files and then execute the jsf:action of the button

只愿长相守 提交于 2019-12-12 04:45:13

问题


The fileupload, as seen in the code, call a method, which saves files in a List <>. The upload files from the button with the ruling PF ('fileupload') upload ().; What I need here is that when you upload the "n" preloaded, recently at the end of the upload, execute the action method of the button.

<p:fileUpload id="fileupload"
              widgetVar="fileupload"
              fileUploadListener="#{incidentBean.handleAttachment}"
              mode="advanced"
              label="Adjuntar (máx. 800kb)"
              invalidFileMessage="Archivo inválido"
              update="form-attachments"
              allowTypes="/(\.|\/)(jpg|jpeg|gif|png)$/"
              multiple="true"
              sizeLimit="820000"
              invalidSizeMessage="Archivo pesado" />

<button class="btn btn-info"
        type="submit"
        jsf:id="cmd"
        jsf:action="#{incidentBean.save()}"
        jsf:onclick="PF('fileupload').fileupload();">

Thanks for the help.


回答1:


You could simply connect the oncomplete attribute of the fileupload to a <p:remoteCommand/>, such that you'll have:

  <p:remoteCommand name="save" actionListener="#{incidentBean.save}"/>

and

  <p:fileUpload id="fileupload" oncomplete="save();"  widgetVar="fileupload"/>


来源:https://stackoverflow.com/questions/26696922/finish-uploading-files-and-then-execute-the-jsfaction-of-the-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!