Note that there are some explanatory texts on larger screens.

plurals
  1. POPrimeFaces p:fileUpload multiple files autoComplete only works after first file
    text
    copied!<p>I try to upload some files then redirect to another page by <code>oncomplete</code> the problem is that <code>oncomplete</code> is only working just after the first file is uploaded </p> <pre><code>&lt;p:fileUpload mode="advanced" label="#{FileMessages.file_add_file_lbl_Select_File}" fileUploadListener="#{fileAddFileAction.upload}" oncomplete="redirect(#{fileAddFileAction.groupId});" multiple="true" allowTypes="/(\.|\/)(txt|doc|docx|pdf)$/" widgetVar="fileUplaod" &gt; &lt;/p:fileUpload&gt; </code></pre> <p>Java Script function: redirect(groupId)</p> <pre><code>function redirect(groupId) { var url = "/network/group/files.html?gId="+groupId; $(location).attr('href',url); } </code></pre> <p>bean.java</p> <pre><code>public void upload(FileUploadEvent event) { UploadedFile uploadedFile = event.getFile(); try { String thumbnail = getDestination() + uploadedFile.getFileName(); String[] filetype = thumbnail.split("\\."); String newfilename = Calendar.getInstance().getTimeInMillis() + "." + filetype[1]; SystemFile file = new SystemFile(); file.setAccount(getActor().getAccount()); file.setCtime(new Date()); file.setName(newfilename); file.setPath(getDestination()); file.setFileType(FileUtil.checkFileType(filetype[1])); file.setOriginalName(uploadedFile.getFileName()); getFileService().saveSystemFile(file); copyFile(getDestination() + newfilename, uploadedFile.getInputstream()); copyFile(getDestination() + newfilename, uploadedFile.getInputstream()); } catch (IOException ex) { Logger.getLogger(FileAddFileAction.class.getName()).log(Level.SEVERE, null, ex); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload