FileUpload: File upload doesn't work with BlockUI
See original GitHub issueDescribe the defect
FileUpload caused an JavaScript exception while uploading a file when a p:blockUI with trigger exists on the same xhtml site. The JavaScript errors is Uncaught TypeError: c.source is undefined
(Firefox) or Uncaught TypeError: Cannot read property 'name' of undefined
(Chrome) and leads to bindTriggers()
function in components.js. Without trigger everything is okay.
Reproducer It is possible to use the primefaces-test-master with the changes below to reproduce. Or download it here https://wetransfer.com/downloads/ee2ed7ea0125fdb6768668e143d7aa5920210519143234/f7ee2e2f941e6febef540fb90656a9c520210519143300/efb561 (available for 7 days).
Environment:
- PF Version: 10.0
- JSF + version: Mojarra 2.2.20
- Affected browsers: ALL
To Reproduce Steps to reproduce the behavior:
- Create a p:blockUI and a p:commandButton
- The trigger of the p:blockUI is the id of the p:commandButton
- Add a p:fileUpload component
- Start application
- Try to upload a file and look at the web console of the browser
Expected behavior File should be uploaded.
Example XHTML
<h1>Primefaces Test - FileUpload with BlockUI</h1>
<h:form id="frmTest">
<p:blockUI widgetVar="blockerObj"
block="frmTest"
trigger="button"/>
<p:commandButton id="button"
value="Click me!"/>
<p:fileUpload id="stopsetFile"
listener="#{testView.handleFileUpload}"
auto="true"
mode="advanced"/>
</h:form>
Example Bean
@Named
@ViewScoped
public class TestView implements Serializable {
@Getter
@Setter
private UploadedFile file;
public void handleFileUpload(final FileUploadEvent event) {
System.out.println("Filename = " + event.getFile().getFileName());
}
public void handleFileUpload(final FilesUploadEvent event) {
for (UploadedFile _file : event.getFiles().getFiles()) {
System.out.println("Filenames = " + _file.getFileName());
}
}
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (6 by maintainers)
Top GitHub Comments
Hello again, it was a problem with Jetty v10. We need some additions to get the file upload work properly:
Found here https://stackoverflow.com/a/51555219.
May be a solution: one unique patch file to keep reviewed. You’re right too. Ok, I evaluate this way with my colleagues. Thanks a lot for the tip!
Best regards