Announcement Announcement Module
No announcement yet.
Access to HttpSession from MultiAction? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Access to HttpSession from MultiAction?

    What's the best way to access the current user's HttpSession from an action-state backed by a MultiAction bean?

    Perhaps a better question:

    What's the best way to pass data from a web-flow action state to a normal Spring MVC Controller via a link (as opposed to a form submit)?

    Here's my scenario:

    I've got a fairly hefty flow that prepares a billing report form data catured across several screens. The last page of the flow is a view-state with some stats on the report and a link/anchor to view the report in a new browser window as either a CSV or Excel file. This last page also has an option for ending the flow.

    The last action-state to execute before said view-state creates the billing report object. I want to place it in the user's session so that my "render report controller" (subclass of spring's MultiActionController) can fetch it, create the report file in the proper format, and stream it to the HttpResponse (and thus, the report is rendered in the new browser window).

    The user can change switch back to the original browser window, and click on a link to render the same report in a different format (Excel). And the same thing happens as the first time, only in a different output format.

    I've been using web-flow for a few days now, and really like it. I'm still getting my head around some of its details and understanding how best to use it.

  • #2
    the simplest thing to do I see is this:

    ((ServletEvent)(context.getSourceEvent())).getRequ est().getSession()...

    Downside as now your action is tied to HTTP -- probably not a big deal, but keep in mind the the spirit of SWF is about keeping yourself independent of the underlying client environment where possible.

    Other options? You could use a flow execution listener here, overriding sessionEnded to do the export to the HttpSession. With PR4 (due out in the coming days) you could also have an entry action on your flow's end state do that work.

    There is no current "global-to-user-session state" abstraction -- e.g data shared by all flows, accessible by non-flow artifacts. Does it make sense? hmmm....


    • #3
      ((HttpServletEvent)(context.getSourceEvent())).get Request().getSession()...
      Where is HttpServletEvent defined? I don't have it in any of my dependent or project jars. I've done a google search and it returns nothing. I've also searched the J2EE 1.4 and JSE 1.5 javadocs. I don't see it anywhere... what am I missing?

      Otherwise, everything you've said makes sense. I will also look into the listener solution, however, I think the above solution is probably easiest (once I can find this class to cast to).



      • #4
        Oops, it's ServletEvent.