3

Somebody told me that JSF 2.0 automatically handles multiple submission problem. Is that right? If yes, how does JSF 2.0 do that? If no, what are the things that must taken care of, so that you don't leave any pitfall while handling this problem?

Thanks.

Bhesh Gurung
  • 50,430
  • 22
  • 93
  • 142

2 Answers2

5

This is requested and maintained by JSF spec issue 559. As it currently stands, it's not there yet, but it is targeted for the upcoming JSF 2.2.

Until then, the Seam's <s:token> is your best solution which not only prevents CSRF (which is not strictly necessary anymore since JSF 2.1 as per JSF impl issue 812), but also double submits.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • We are not using Seam. We are using JSF 2.0 and Prime Faces. Any idea or suggestion? – Bhesh Gurung May 05 '11 at 20:17
  • 1
    Do you want to handle this clientside or serverside? If clientside, check the JavaScript `setTimeout()` approach in [this answer](http://stackoverflow.com/questions/1750625/how-do-i-prevent-form-resubmission-in-seam/1751464#1751464). If serverside, I think checking and setting a boolean property in the action method of a view scoped bean is the easiest. For a more advanced solution, using a fullworthy token, you may get some ideas out of [this article](http://jroller.com/mert/entry/jsf_preventing_double_form_submit). – BalusC May 05 '11 at 20:56
0

<h:commandButton onclick ="setTimeout('document.getElementById(\'' + this.id + '\').disabled=true;', 50);setTimeout('document.getElementById(\'' + this.id + '\').disabled=false;', 500);" />

Thought of improving upon your simple yet elagent solution. I think we should enable the submit button after some time. I'm sure you would have thought of this, but this is for other newbie readers like me :-)

gautirao
  • 130
  • 10