I used quite a lot of AJAX when submitting forms in Spring. Basically, what I did was that I created a form.jsp file, which then returns from an AJAX call. Since AJAX will return the entire form with all available form tags, I get all the benefits of server side validation.
So, if I have a page containing a form, I could, for example, have a div that acts as a form container
<div id="form-container"> <form id="myform"> Normal form here ... </form> </div>
And when I submit the form, I can load form.jsp using jQuery for example
$('#myform').submit(function() { $('#form-container').load('ajax/somehandler'); });
So all you have to do is return form.jsp from the controller with all the normal connections, as well as with the non-AJAX approach. Do you have an idea?
source share