Results 1 to 5 of 5

Thread: Filter sets request attribute, but its not in requestContext

  1. #1
    Join Date
    Aug 2004
    Posts
    1,905

    Default 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. #2
    Join Date
    Aug 2004
    Posts
    1,905

    Default 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?

  3. #3
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    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
    Keith Donald
    Core Spring Development Team

  4. #4
    Join Date
    Aug 2004
    Posts
    1,905

    Default 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?

  5. #5
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    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.
    Keith Donald
    Core Spring Development Team

Similar Threads

  1. Replies: 11
    Last Post: Jun 1st, 2006, 04:30 PM
  2. Hibernate Long Session Per Flow?
    By akw in forum Web Flow
    Replies: 21
    Last Post: Dec 12th, 2005, 08:06 PM
  3. Replies: 9
    Last Post: Nov 1st, 2005, 10:36 PM
  4. Loosing my SecureContext
    By sklakken in forum Security
    Replies: 3
    Last Post: Jul 21st, 2005, 01:44 PM
  5. Replies: 5
    Last Post: Mar 18th, 2005, 04:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •