question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FileUpload: File upload doesn't work with BlockUI

See original GitHub issue

Describe 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:

  1. Create a p:blockUI and a p:commandButton
  2. The trigger of the p:blockUI is the id of the p:commandButton
  3. Add a p:fileUpload component
  4. Start application
  5. 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:closed
  • Created 2 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Charriu83commented, Jun 8, 2021

Hello again, it was a problem with Jetty v10. We need some additions to get the file upload work properly:

        // add MultipartConfigInjectionHandler to make Primefaces FileUpload working
        MultipartConfigInjectionHandler multipartConfigInjectionHandler = new MultipartConfigInjectionHandler();
        HandlerCollection collection = new HandlerCollection();
        collection.addHandler(context); // add all "real" handlers
        multipartConfigInjectionHandler.setHandler(collection);

Found here https://stackoverflow.com/a/51555219.

0reactions
aghartacommented, Sep 1, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

p:fileUpload doesn't work with pe:blockUI in same page
I have found an idea, enable and disable the block in the p:fileUpload UI events instead of setting a trigger in the blockUI...
Read more >
FileUpload : Ajax broken when BlockUI present #7151 - GitHub
When mode="simple" and auto="false", the exception is not thrown and file is uploaded OK. Likewise, removing the BlockUI component from the page ...
Read more >
p:fileUpload doesn't work with p:blockUI in same page
The error occurs after loading the first file javascript error occurs and then can not continue using the file upload component
Read more >
how to block ui while file upload ? - CodeProject
i have to upload a file to server using file upload control in asp.net ,but this process takes time so i have to...
Read more >
How to unblockUI after file upload to browser - MSDN - Microsoft
hi,. I have a button which after it is clicked, it uploads a PDF file to the browser. I initiate .blockUI() once the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found