问题
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