The best place to *find* answers to programming/development questions, imo, however it's the *worst* place to *ask* questions (if your first question/comment doesn't get any up-rating/response, then u can't ask anymore questions--ridiculously unrealistic), but again, a great reference for *finding* answers.

My Music (Nickleus)

20130819

richfaces rich:inputNumberSpinner - how to disable form submit on enter key press

this tutorial has a quite complicated/lengthy solution, which involves recompiling source code: How to disable form submit on Enter and fix for RichFaces rich:inputNumberSpinner

my solution is way simpler:
open richfaces-ui-3.3.3.Final.jar in an archive manager

then open this file in a text editor (double click the file):
/org/richfaces/ui.pack.js

beginning around line 15151, you'll see the following lines:
}if(A.keyCode==13){if(this.spinner.required||""!=this.edit.value){this.edit.value=this.getValidValue(this.edit.value)
}if(this.edit.form){this.edit.form.submit()

change the second line so it looks like this:
}if(this.edit.form){/*COMMENTED OUT BY ME: this.edit.form.submit()*/

when you save the file ui.pack.js in the text editor, the archive manager should ask you if you want to update the jar file, choose Update

clear your browser cache, stop your app server, rebuild your project, then restart your server, then test it out in the browser and you should now be able to hit the enter key in a rich:inputNumberSpinner without submitting the form :)



see also: How to stop page refresh when hit enter button from rich:inputNumberSpinner field?

and here's the bug registered in the jboss issue tracker:
inputNumberSpinner: autosubmit of a form while pressing the ENTER KEY, validation is discarded and modal panel is closed

No comments:

Post a Comment