Announcement Announcement Module
Collapse
No announcement yet.
Filter sets request attribute, but its not in requestContext Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Filter sets request attribute, but its not in requestContext

    Hi all,

    I am an absolute newbie to spring webflow, so apologies if this is a really stupid question.

    I basically developed my web app using spring mvc (for which I am not a newbie ). At the moment I have various filters which populate certain request attributes (ServletRequest.setAttribute).

    The problem is that when I get hold of a RequestContext in my action I cannot seem to find any of these attributes, I have tried:

    Scope requestScope = requestContext.getRequestScope();
    Scope flowScope = requestContext.getFlowScope();
    Map scope = requestContext.getModel();

    And none of these contain any of the attributes I have set.

    The filters are definately working because I can step through them. The rest of the app which also uses these attributes (ServletRequest.getAttribute) also work correctly.

    I am completely stuck.

    As a wider problem, the integration of webflow into an existing web app is extremely high to the abstraction of the ServletRequest. I can see how writing an app from scratch wouldn't be a problem, but it would be really nice if there was an easy way to get at the ServletRequest

    Many thanks,

    Col

    P.S. Urgency is very much appreciated as this is a huge sticking point.

  • #2
    Almost there

    OK, so I am getting a bit further

    I have now registered a FlowExecutionListener that simply copies all the servletRequest attributes into the requestContext.getRequestScope().

    Not sure I should have to do this though? Why are parameters available from requestContext, but not attributes?

    Comment


    • #3
      To access the attributes of the underlying http request, you need to access the HttpServletRequest object directly like:

      ((HttpServletEvent)context.getSourceEvent()).getRe quest();

      Or, like you did, you can use a FlowExecutionListener to do that and place the attributes in request scope.

      Keith

      Comment


      • #4
        Shouldn't the request attributes be present already though?

        But shouldn't the request attributes be available through the requestContext anyway?

        Not sure why you would *not* want request attributes available?

        Comment


        • #5
          Well, the flow request scope != servlet request scope. What if I'm running in a Portlet environment?

          We've taken the stance to date that if you need access to the underlying request, either downcast the source event or put what you need into flow request scope from a flow execution listener.

          I have not found a large need for access to request attributes in practice. Request parameters, much more common obviously, are consistently accessible as source event parameters.

          Comment

          Working...
          X