Reputation: 35
<p:commandButton value="Get Name List" update="nameinfo"/>
<p:dataTable id="nameinfo" var="nam" value="#{namefinder.dofind}"></p:dataTable>
"dofind" is the method which find the name list and it return the value as namefinder class object list
Problem is: "dofind" method is call 7 times.
why doing like this?
Upvotes: 3
Views: 3776
Reputation: 22847
Because this is the way JSF is working, and this is correct according to Java Bean principles. Getter can be called multiple times, as much as the caller wishes.
The value
attribute of p:dataTable
expects getter method and is calling that method multiple times. You can't guarantee how many times will a getter be called. Instead, you should do no logic in getter method.
Instead, provide the method that will be called by your p:commandButton
and refresh the collection there. dofind
should be the field of JavaBean with the list of rows, no logic should be done there.
Upvotes: 5