FileUpload: show function in client API doesn't work for the second time
See original GitHub issue** using client API FileUpload can’t call listener method ** Calling show function of FileUpload same as #5373
Environment:
- PF Version: 10.0
- JSF + version: Mojarra 2.2.19
- Affected browsers: Safari Chrome may be any browser.
To Reproduce Steps to reproduce the behavior:
- Click on button ‘CSV Upload’
- Click on menu item ‘0’
- Chose some file
- Repeat these steps
- FileUpload doesn’t call listener method at twice
Expected behavior FileUpload should call listener method repeatedly
Example XHTML
<h:head/>
<h:body>
<f:view>
<h:form>
<p:growl id="growl"/>
<p:menuButton value="CSV Upload">
<p:menuitem value="0" onstart="PF('upload0').show()"/>
<p:menuitem value="1" onstart="PF('upload1').show()"/>
<p:menuitem value="2" onstart="PF('upload2').show()"/>
<p:menuitem value="3" onstart="PF('upload3').show()"/>
<p:menuitem value="4" onstart="PF('upload4').show()"/>
<p:menuitem value="5" onstart="PF('upload5').show()"/>
<p:menuitem value="6" onstart="PF('upload6').show()"/>
<p:menuitem value="7" onstart="PF('upload7').show()"/>
<p:menuitem value="8" onstart="PF('upload8').show()"/>
<p:menuitem value="9" onstart="PF('upload9').show()"/>
</p:menuButton>
<p:fileUpload widgetVar="upload0" auto="true" style="display:none;" listener="#{UploadTest.uploadCsv0}" update="growl"/>
<p:fileUpload widgetVar="upload1" auto="true" style="display:none;" listener="#{UploadTest.uploadCsv1}" update="growl"/>
<p:fileUpload widgetVar="upload2" auto="true" style="display:none;" listener="#{UploadTest.uploadCsv2}" update="growl"/>
<p:fileUpload widgetVar="upload3" auto="true" style="display:none;" listener="#{UploadTest.uploadCsv3}" update="growl"/>
<p:fileUpload widgetVar="upload4" auto="true" style="display:none;" listener="#{UploadTest.uploadCsv4}" update="growl"/>
<p:fileUpload widgetVar="upload5" auto="true" style="display:none;" listener="#{UploadTest.uploadCsv5}" update="growl"/>
<p:fileUpload widgetVar="upload6" auto="true" style="display:none;" listener="#{UploadTest.uploadCsv6}" update="growl"/>
<p:fileUpload widgetVar="upload7" auto="true" style="display:none;" listener="#{UploadTest.uploadCsv7}" update="growl"/>
<p:fileUpload widgetVar="upload8" auto="true" style="display:none;" listener="#{UploadTest.uploadCsv8}" update="growl"/>
<p:fileUpload widgetVar="upload9" auto="true" style="display:none;" listener="#{UploadTest.uploadCsv9}" update="growl"/>
</h:form>
</f:view>
</h:body>
Example Bean
@ManagedBean(name="UploadTest")
@ViewScoped
public class UploadTestManagedBean {
public void uploadCsv0(FileUploadEvent event){uploadCsv(event.getFile(), 0);}
public void uploadCsv1(FileUploadEvent event){uploadCsv(event.getFile(), 1);}
public void uploadCsv2(FileUploadEvent event){uploadCsv(event.getFile(), 2);}
public void uploadCsv3(FileUploadEvent event){uploadCsv(event.getFile(), 3);}
public void uploadCsv4(FileUploadEvent event){uploadCsv(event.getFile(), 4);}
public void uploadCsv5(FileUploadEvent event){uploadCsv(event.getFile(), 5);}
public void uploadCsv6(FileUploadEvent event){uploadCsv(event.getFile(), 6);}
public void uploadCsv7(FileUploadEvent event){uploadCsv(event.getFile(), 7);}
public void uploadCsv8(FileUploadEvent event){uploadCsv(event.getFile(), 8);}
public void uploadCsv9(FileUploadEvent event){uploadCsv(event.getFile(), 9);}
public void uploadCsv(UploadedFile data, int fileId){
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "FileId:" + fileId, null));
}
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:20 (18 by maintainers)
Top Results From Across the Web
Filereader - upload same file again not working - Stack Overflow
reader.onload was not uploading the same file a second time on the change event . I was using pure javascript , and here...
Read more >How You Can Fix The Biggest Problem With React File Upload
This step is crucial in view of uploading files because you must set the content type to multipart/form-data, or else it won't run...
Read more >Using files from web applications - Web APIs - MDN Web Docs
The FileUpload function accepts two inputs: an image element and a file from which to read the image data. ... The FileUpload() function...
Read more >Handling File Uploads With Flask - miguelgrinberg.com
In this article I'm going to show you how to implement a robust file upload feature for your Flask server that is compatible...
Read more >Upload file data | Drive API - Google Developers
The Google API client libraries implement at least one of these types of ... fixed time limit for any single request, or you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
yeah please i think we could reset automatically somehow? update=@this is just a hack IMO
Actually
update="@this growl"
is even better. The fileUpload itself needs to be updated after to reset it.