0

I want to prevent from multiple clicking button in JSF but every attempt does not work. Action in that button is responsible for loading data to table. I have something like that:

<h:commandButton class="inputButton bFind" action="#{backingBean.load}" value="#{msgc.find}" />

but that line allows users to click that button even before action ends.

When I try to do something like that:

<a4j:commandButton class="inputButton bFind" onclick="this.disabled=true" oncomplete="this.disabled=false" action="#{backingBean.load}" value="#{msgc.find}" />

or

<a4j:commandButton class="inputButton bFind" onclick="this.disabled=true" oncomplete="this.disabled=false" action="#{backingBean.load}" value="#{msgc.find}" />

then button is blocked and its prevent from multiple clicking but then I must refresh site to see data in table. :/ I have no idea what i should do to this.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
John
  • 363
  • 2
  • 6
  • 19
  • Check out [this](http://stackoverflow.com/q/6482443/1391249) (it is for PrimeFaces though). – Tiny Jul 12 '14 at 19:50
  • 1
    First way (with `h:commandButton`) performs a standard submit to the server. The other one ((with `a4j:commandButton`)) performs an ajax request which doesn't render your table by default, unless you specify it in its `reRender` attribute. – Aritz Jul 12 '14 at 22:18

1 Answers1

0

Ok i did it. Thx "@Xtreme Biker" for help. All what I need to do is add reRender attribute:

<a4j:commandButton class="inputButton bFind" onclick="this.disabled=true" oncomplete="this.disabled=false" action="#{backingBean.load}" reRender="dataTable_#{backingBean.id}" value="#{msgc.find}" />

and put content which should be rerendered to

<a4j:outputPanel id="dataTable_#{backingBean.id}" ajaxRendered="true">
</a4j:outputPanel>
John
  • 363
  • 2
  • 6
  • 19