Announcement Announcement Module
Collapse
No announcement yet.
Access ref data in onsubmit() in SimpleFormController Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Access ref data in onsubmit() in SimpleFormController

    Hi All

    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
    ((HashMap)command).putAll(refdata);


    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.

    Thanks

    Gareth.
    Last edited by mrbluesbox; Jan 4th, 2008, 10:47 AM.

  • #2
    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.

    Comment


    • #3
      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.

      Gareth.

      Comment

      Working...
      X