Jan 4th, 2008, 09:39 AM
Access ref data in onsubmit() in SimpleFormController
i was wondering if it was possible to access the reference data from within the onsubmit method WITHOUT recalling referencedata() - i have a call to a web service in ref data that could be quite slow and dont particularly want to call it twice.
Ive tried overriding the protected Map referenceData(HttpServletRequest request, Object command, Errors errors) method and doing this :
//Add all the elements to the command map as we want refdata and command to be the same
but (i assume) because im not binding the refdata fields back to the form im not getting any data back in the onsubmit method.
Any suggestion as to why this doesnt work or any alternative solutions would be very greatly recieved.
Last edited by mrbluesbox; Jan 4th, 2008 at 09:47 AM.
Jan 4th, 2008, 09:57 AM
I believe by default referenceData is not called at all if the form is submitted, so if you explicitly called it in your onSubmit, it would be the first (and only) time during the span of the request.
Peter Mularien | Blog
Author, Spring Security 3 (Book) - Packt Publishing, Available in print and eBook form
SCJP 5, Oracle DBA
Any postings are my own opinion, and should not be attributed to my employer or clients.
Jan 4th, 2008, 10:09 AM
thanks for the reply.
yup i think thats correct - reference data is only called on the post i.e. when the form is displayed not on the submit, but the prob that i had was i needed to access the ref data in the on submit aswell as on the on submit method (im writing an add to basket confirmation page, where the price of the object im adding to the basket needed to be priced using a web service and displayed on the web page but i also needed that price to do some calculations in onsubmit aswell and didnt want to call the web service twice).
i just sussed out the problem though - i hadnt set my sessionForm variable to true, so the command would have been recreated in onsubmit. i set this to true and eveything works great. should always try the easy things first lol.