Surfaces: <p: ajax inside DataTable data handling method multiple times after dataTable is updated
The problem is this: "p: ajax event =" rowDblselect "listener =" # {companyBean.update ()} "..." when I doubleClick the first time, the "update ()" method is called once (Perfect! ), but after that, when I click on the commandButton "button1" and I doubleClick on the component again, "update ()" is called 2 times. When I repeat again, "update ()" gets called 3 times ............ This is very strange! I think that when I update the datatable using commandButton, the ajax event keeps updating to itself. I don't know (?) ... Can anyone help me solve it?
<h:panelGrid id="panel" columns="5">
<p:commandButton id="button1" value="Search" actionListener="#{
companyBean.search()}" update="dataTable"/>
</h:panelGrid>
<p:dataTable id="dataTable" var="companyTO" value="#{companyBean.companiesTO}"
selection="#companyBean.selectedCompanyTO}" rowKey="#{companyTO}"
emptyMessage="" selectionMode="single" >
<p:ajax event="rowDblselect" listener="#{companyBean.update()}" immediate="true"
process="@this" />
<p:column >
...
<p:dataTable>
obs: When I remove the "update =" dataTable, "event =" rowDblselect "" works fine, call the method only once. So the problem is with the update.
I found the same problem: https://stackoverflow.com/questions/11904556/updating-datatable-with-own-datamodel-calls-method-more-and-more
source to share
Try to remove the attribute of immediate
your event ajax
and commandbutton
add the attributes:
process="@this" partialSubmit="true" ajax="true"
Like this:
Event:
<p:ajax event="rowDblselect" listener="#{companyBean.update()}" process="@this" partialSubmit="true" />
Button:
<p:commandButton id="button1" value="Search" actionListener="#{
companyBean.search()}" update="dataTable" process="@this" partialSubmit="true" ajax="true"/>
source to share