What is the difference between onclick and onstart?
e.g.
<p:commandButton id="checkout" value="Complete Checkout" action="#{checkoutBean.checkout}" update="@form"
onclick="PF('blockui').block()" onstart="PF('blockui').block()" oncomplete="PF('blockui').unblock()"/>
onclick = being invoked prior to the actual form submission / prior to the ajax call (and that's why calling return false; in onclick prevents the flow of form submission/ajax call - in other words onclick is called before the action of the button.
The onclick event occurs when the user clicks on an element
onstart = being invoked after the onclick and its the first phase of ajax flow from client to server, once you there, your ajax has begun and you can't really stop it...
The onstart event occurs when ajax call is about to start
IMO, you better be consistent and call your PF('blockui').block() code in onstart since you stopping it on oncomplete (both are ajax related phases), and keep the onclick usage for other purposes (maybe for some reason you would like to place a conditional statement that might call return false; which will prevent your ajax from being called at all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With