Announcement Announcement Module
No announcement yet.
Accessing session from SimpleFormController Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Accessing session from SimpleFormController

    I have a class that extends SimpleFormController. The command object that's passed into the onSubmit is my user that's in the session. I want to be able to access the session in my onSubmit method to update the now 'dirty' user that's in the session. Is there a handle to the session anywhere?

    Thanks in advance.

  • #2
    If you have access to the HttpServletRequest object then you should be able to get the HttpSession (if thats what you mean by session).


    • #3
      Thanks for the reply -

      Yes, the HttpSession is the session I meant, and I can get it from the HttpServletRequest, but that's only passed in to the formBackingObject method, not the onSubmit method of SimpleFormController. I'm looking to be able to update the session after the form is submitted.

      I guess I could pull the session off the request in the formBackingObject method and save it in my controller for use later, but that seems kinda hacky, and I would think the request would be made available to the onSubmit method, just because who knows what information you need off the request at the time of form submittal.

      Am I missing something?



      • #4

        The onSubmit() method actually has a number of convenient overloads. Simply overload that version of the onSubmit() method that provides access to the HttpServletRequest; to wit...

        The forum's a bit buggy, so I can't paste a link straight to the overload you want. Guess you'll have to scroll down



        • #5
          Ahhh...that's exactly what I was looking for. The sad part is that I looked at the docs and completely overlooked that, looking for some kind of getter for the HttpServletRequest or HttpSession.