Reputation: 170
I've got the code below. I removed facets and similar tags, to make it more readable. I highly doubt they are the issue. I'm using Primefaces 6.1 for all tags, except the form tag is Omnifaces.
<h:form id="form">
<p:dataTable id="table" value="#{data.rows}" var="row" rowIndexVar="index">
<p:column id="ajaxColumn" rendered="#{true}">
<p:inputText id="ajaxValue" value="#{row.ajaxValue}">
<p:ajax event="blur" process="@this" update="@this form-table-#{index}-targetColumn" listener="#{bean.ajaxMethod(index)}"/>
</p:inputText>
<p:column>
<p:column id="targetColumn"rendered="#{true}">
<p:inputText id="targetValue" value="#{row.targetValue}"/>
</p:column>
</p:dataTable>
</h:form>
I want to update the 'targetValue' inputText with a new value, after the 'ajaxValue' inputText deselection caused a blur event. The ajax call should send the value inside 'ajaxValue' to the backend and set the 'targetValue' in the bean accordingly. After that the 'targetValue' should update with the new value.
My problem is that when I add "form-table-#{index}-targetColumn" to the update attribute of the ajax tag, the 'targetValue' remains empty from the start. It has no value on the frontend. If I add "form-table-0-targetColumn" instead, only the first 'targetValue' won't have a value.
Looking at the getter calls while debugging, their behavior is identical, whether I have the update attribute or not.
Any ideas?
EDIT: To clarify. The separators in the ID are meant to be '-', not ':', as they are usually, I believe.
Upvotes: 0
Views: 524
Reputation: 12337
In a datatable you cannot use the index to update in rows. If you want to update some element that is in the same row, You should just use update="targetColumn".
(There must be a duplicate of this somewhere, but I cannot find it and until I do, I'll leave this answer here
Upvotes: 1