Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileUpload: simple & auto doesnt work anymore #7352

Closed
tandraschko opened this issue May 25, 2021 · 4 comments · Fixed by #7353
Closed

FileUpload: simple & auto doesnt work anymore #7352

tandraschko opened this issue May 25, 2021 · 4 comments · Fixed by #7353
Assignees
Labels
10.0.2 🐞 defect Bug...Something isn't working workaround A workaround has been provided
Milestone

Comments

@tandraschko
Copy link
Member

            <h:form enctype="multipart/form-data">
                <p:growl id="growl"/>
                <p:menuButton value="CSV Upload">
                    <p:menuitem value="0" onclick="PF('upload0').show(); return false;"/>
                </p:menuButton>
                <p:fileUpload widgetVar="upload0" mode="simple" auto="true" style="display:none;" listener="#{UploadTest.uploadCsv0}" update="growl"/>
            </h:form>
@tandraschko tandraschko added the 🐞 defect Bug...Something isn't working label May 25, 2021
@tandraschko
Copy link
Member Author

i liked to suggest this approach for #7284 as simple mode fits better. But it seems its broken.

@melloware would you like to check it?
seems like

this.input.on('change.fileupload', function() {

is registred but the handler is never called? at least in my firefox

@melloware
Copy link
Member

Let me check it out.

@melloware
Copy link
Member

MonkeyPatch if someone needs it:

if (PrimeFaces.widget.SimpleFileUpload) {
    PrimeFaces.widget.SimpleFileUpload.prototype.init = function(cfg) {
        PrimeFaces.widget.DeferredWidget.prototype.init.call(this, cfg);
        if (this.cfg.disabled) {
            return;
        }

        this.cfg.invalidFileMessage = this.cfg.invalidFileMessage || 'Invalid file type';
        this.cfg.invalidSizeMessage = this.cfg.invalidSizeMessage || 'Invalid file size';
        this.cfg.fileLimitMessage = this.cfg.fileLimitMessage || 'Maximum number of files exceeded';
        this.cfg.messageTemplate = this.cfg.messageTemplate || '{name} {size}';
        this.cfg.global = (this.cfg.global === true || this.cfg.global === undefined) ? true : false;
        this.sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];

        this.maxFileSize = this.cfg.maxFileSize;

        this.form = this.jq.closest('form');
        this.input = $(this.jqId);

        if (this.cfg.skinSimple) {
            this.button = this.jq.children('.ui-button');
            this.display = this.jq.children('.ui-fileupload-filename');

            if (!this.input.prop('disabled')) {
                this.bindEvents();
            }
        } else if (this.cfg.auto) {
            var $this = this;
            this.input.on('change.fileupload', function() {
                $this.upload();
            });
        }
    }
};

@melloware melloware added workaround A workaround has been provided elite This issue is related to an Elite release labels May 25, 2021
@tandraschko
Copy link
Member Author

Thanks!

@buunsal buunsal added 10.0.2 and removed elite This issue is related to an Elite release labels May 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
10.0.2 🐞 defect Bug...Something isn't working workaround A workaround has been provided
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants