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

DataTable: addRow() widget method should use partialSubmit and avoid posting all inputs #3564

Closed
tandraschko opened this issue Apr 9, 2018 · 7 comments · Fixed by #11160
Closed
Labels
enhancement Additional functionality to current component
Milestone

Comments

@tandraschko
Copy link
Member

No description provided.

@tandraschko tandraschko added the enhancement Additional functionality to current component label Apr 9, 2018
@tandraschko tandraschko changed the title Editable DataTable: addRow() widget method should use partialSubmit and post not all inputs Editable DataTable: addRow() widget method should use partialSubmit and avoid posting all inputs Apr 9, 2018
@tandraschko tandraschko added the Resolution: Duplicate Issue has already been reported or a pull request related to same issue has already been submitted label Apr 10, 2018
@tandraschko
Copy link
Member Author

Close in favor of: #3571

@kukel
Copy link
Contributor

kukel commented Apr 10, 2018

First of all, this has nothing to do with the EditableDatatable. It happens for a normal datatable with inputs as well. I've analyzed all this and the addRow by default processes the children of the datatable but submits the whole surrounding form (the default if nothing else is specified)

    addRow: function() {
        var $this = this,
        options = {
            source: this.id,
            process: this.id,
            update: this.id,
            params: [{name: this.id + '_addrow', value: true},
                    {name: this.id + '_skipChildren', value: true},
                    {name: this.id + '_encodeFeature', value: true}],
            onsuccess: function(responseXML, status, xhr) {
                PrimeFaces.ajax.Response.handle(responseXML, status, xhr, {
                    widget: $this,
                    handle: function(content) {
                        this.tbody.append(content);
                    }
                });

                return true;
            }
        };

        PrimeFaces.ajax.Request.handle(options);
},

By changing the process: this.id to process: "@none" AND adding a partialSubmit: true, the addRow() does not submit anything.

This might however break existing functionality since if I remember correctly, in IE the blur/click events might be in a different order, so the submission of the editable input in the onblur event might occur after clicking a button that does an 'addRow()'. So maybe an additional addRow(boolean partialSubmit) is a safer backwards compatible way to solve this.

@kukel
Copy link
Contributor

kukel commented Apr 10, 2018

So I vote to re-open this. It is as stated NOT related to an editableDataTable and removing that from the title makes it a generic issue.

@tandraschko tandraschko changed the title Editable DataTable: addRow() widget method should use partialSubmit and avoid posting all inputs ataTable: addRow() widget method should use partialSubmit and avoid posting all inputs Apr 10, 2018
@tandraschko tandraschko removed the Resolution: Duplicate Issue has already been reported or a pull request related to same issue has already been submitted label Apr 10, 2018
@tandraschko tandraschko reopened this Apr 10, 2018
@tandraschko tandraschko changed the title ataTable: addRow() widget method should use partialSubmit and avoid posting all inputs DataTable: addRow() widget method should use partialSubmit and avoid posting all inputs Apr 10, 2018
@tandraschko
Copy link
Member Author

tandraschko commented Apr 10, 2018

I think you need a process=datatable, so that the datatable can trigger teh AddRowFeature.
A simple fix would be to filter out, via partialSubmitParameterFilter, all child parameters of the datatable. Similar, but much smaller, as: a0cc0ca

@kukel
Copy link
Contributor

kukel commented Apr 10, 2018

The addRowFeature seems to be working without it... I checked live in the showcase. The feature is triggered by a special parameter in the request https://github.com/primefaces/primefaces/blob/master/src/main/java/org/primefaces/component/datatable/feature/AddRowFeature.java#L52 which still is there (form%3Acars2_addrow=true for the showcase)! But I'll check never the less...

@kukel
Copy link
Contributor

kukel commented Apr 10, 2018

The AddRowFeature is normally called, so it is a fix... maybe the 'skipChildren' attribute of the datatable can be used as well to do a 'partialSubmit' by default or not...

@tandraschko
Copy link
Member Author

I will close it for now. No work done here and #3571 would be the real way IMO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Additional functionality to current component
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants