0

I have a jsf <p:commandButton> in my xhtml page.I need to call a function in the bean class with this button click and I need to disable the button so that if user click it again the bean class method should not call again and again.I tried many examples. The button is appeared to be disabled but if I click it again and again the bean class method is called again and again.How can I avoid this.This is the code currently I have.

<p:commandButton ajax="false" action="#{targetAchievementBean.calculate()}" value="Calculate" onclick="jQuery(this).addClass('ui-state-disabled')"/>

Please be specific with the question because I have tried many examples.Help me on this.

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
chinthi
  • 87
  • 2
  • 11
  • @BalusC why it is marked as duplicate?The answer that you point is about I want to know this about .If you know the answer please let me know instead of marking it as duplicate – chinthi Aug 22 '16 at 13:37
  • Sorry I did not understand it. Can you please tell me with my code which I have mentioned?What I need is to call the calculate method only once and make the button disable . – chinthi Aug 22 '16 at 13:43
  • PrimeFaces ClientSide API provides a very simple way to disable the button: `onclick="PF('buttonWidget').disable();"` – stg Aug 23 '16 at 10:24

0 Answers0