Primefaces dataTable call method multiple times when click commandButton. why?

前端 未结 1 1180
渐次进展
渐次进展 2020-12-21 06:30



        
相关标签:
1条回答
  • 2020-12-21 06:51

    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.

    0 讨论(0)
提交回复
热议问题