Why is ajax cellEdit event sending @this regardless of value of the process attribute?

Components, Ajax Framework, Utilities and More.
Post Reply
RElliott
Posts: 82
Joined: 07 Feb 2014, 00:39

16 Jul 2017, 14:34

My client implements a treeTable as shown below:

Code: Select all

<p:treeTable
    id="steps"
    value="#{checklistPC.treeNode}"
    var="step"
    paginator="false"
    editable="true"
    editMode="cell"
    reflow="true">
    <p:ajax
        event="cellEdit"
        listener="#{checklistPC.onCellEdit}"
        partialSubmit="true"
        process="@this" />
        ,,,,
I noticed that when I edit any field in the treeTable ajax submits all the rows of the treetable. In order to reduce the amount of data sent from the client to the server, I experimented with the process attribute but was unable to get ajax to only send the edited field or the current row. As a test, I made the following change to the process attribute of my treeTable.

Code: Select all

<p:treeTable
    id="steps"
    value="#{checklistPC.treeNode}"
    var="step"
    paginator="false"
    editable="true"
    editMode="cell"
    reflow="true">
    <p:ajax
        event="cellEdit"
        listener="#{checklistPC.onCellEdit}"
        partialSubmit="true"
        process="@([data-rk='1')" />
        ,,,,
When I observed the Network traffic using the Chrome developer tools, I noticed that the javax.faces.partial.execute value included the row 1 ID as expected but also include the treeTable ID.

When I reviewed my other tests, I confirmed that ajax always sends the treeTable ID regardless of the value of the process attribute so it appears to be impossible to limit treeTable to sending anything less than the entire table.

Is there a reason for this behaviour?

The following are some similar links:

https://stackoverflow.com/questions/162 ... jax-submit
https://stackoverflow.com/questions/230 ... -selection
PrimeFaces 6.1, Glassfish 4.1.2, Oracle JDK 8, Eclipse Luna

djmj
Posts: 381
Joined: 16 Dec 2011, 01:23

17 Jul 2017, 02:38

Did you tried skipChildren="true" on datatable?

I confirm this behaviour and want to add that the default filter event, like PF('tblWidgetVar').filter(); also processes all data inside a table. That is a problem in our use case.

I have an editable table that is always editable without using cellEditor component. This is used for mass-editing and quickly adding new data.
A custom button saves the changes of the row.

Code: Select all

	
	
	<!-- name -->
	<p:column headerText="Name">
		<p:inputText id="name" value="#{varProduct.name}" required="true"/>
	</p:column>

	<!-- save -->
	<p:column headerText="Name">
		<p:commandButton value="Save" process="@this, name" action="#{bean.save(varProduct)}>
	</p:column>
Bug

If the user filters any column, the data gets filtered successfully and returns new data.
In case name value of the new data is null the name inputText is marked red since it is required.
So basically its validation failed, before user clicked the save button?

Workaround

Since my problem is just client-side and GUI related i just remove the class again after filter event:

Code: Select all

<p:ajax event="filter" oncomplete="$(PrimeFaces.escapeClientId('#{component.clientId}') + ' :input').removeClass('ui-state-error');"/>
Last edited by djmj on 17 Jul 2017, 23:40, edited 1 time in total.
Primefaces: 5.3
Primefaces-Extension: 4.0.0
Jsf: Mojarra 2.2.9
Server: Glassfish 4.1

RElliott
Posts: 82
Joined: 07 Feb 2014, 00:39

17 Jul 2017, 23:04

My treeTable still sends all the table data to the server during cellEdit when skipChildren="true". Also, setting skipChildren="true" breaks the cellEdit. The documentations states that skipChildren "Ignores processing of children during lifecycle..." so it makes sense that you cannot have skipChildren="true" with an editable treeTable.

Based on my reading and testing, I believe that a treeTable with editable="true" and editMode="cell" will always send all the table data to the server regardless of the value of the p:ajax process attribute and that the only way to change this would be to change the PrimeFaces code as described in the following link:

https://stackoverflow.com/questions/162 ... jax-submit
PrimeFaces 6.1, Glassfish 4.1.2, Oracle JDK 8, Eclipse Luna

djmj
Posts: 381
Joined: 16 Dec 2011, 01:23

17 Jul 2017, 23:40

Yes you are right. I think PrimeFaces should reconsider which data is necessery for each event to send.
Or use corresponding p:ajax process attribute selector to allow developer to get full control.
Primefaces: 5.3
Primefaces-Extension: 4.0.0
Jsf: Mojarra 2.2.9
Server: Glassfish 4.1

RElliott
Posts: 82
Joined: 07 Feb 2014, 00:39

19 Jul 2017, 01:22

I logged the following issue in the PrimeFaces issue tracker.

https://github.com/primefaces/primefaces/issues/2551
PrimeFaces 6.1, Glassfish 4.1.2, Oracle JDK 8, Eclipse Luna

Post Reply
  • Information
  • Who is online

    Users browsing this forum: Baidu [Spider] and 9 guests