Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8896663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:07:53+00:00 2026-06-15T00:07:53+00:00

I have a HandlerInterceptor to add some global model variables. It works. Now, I

  • 0

I have a HandlerInterceptor to add some “global” model variables. It works.

Now, I try to reuse it in Spring Web Flow, for the same reason.

But HandlerInterceptors have the ModelAndView parameter set to NULL under Spring Web Flow (couldn’t figure why, but it’s a fact).

I have referenced my interceptor in the FlowHandlerMapping bean :

<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping"> 
    <property name="order" value="0" /> 
    <property name="flowRegistry" ref="flowRegistry" />
    <property name="interceptors">
        <list>
            <ref bean="myInterceptor" />
        </list>
    </property>
</bean>

How can I add variables to the model ?

Is there a workaround, with the request parameter for example ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T00:07:54+00:00Added an answer on June 15, 2026 at 12:07 am

    Starting with Spring Webflow 2, the ModelAndView object is not generated anymore (see this post (and thread) at the SpringSource forum).


    The FlowHandlerAdapter handle() function does not generate a ModedAndView anymore (it just returns null) even if this function is :

    public ModelAndView handle(HttpServletRequest request, 
            HttpServletResponse response, Object handler)
    

    So overriding this function is pointless, but this function creates a ServletExternalContext object, which holds all the flow variable, by calling its method :

    protected ServletExternalContext createServletExternalContext(
        HttpServletRequest request, HttpServletResponse response)
    

    By overriding this function you can pretty much do what you want with this flow variables.


    To do this, just create a class that extends FlowHandlerAdapter, register it instead of FlowHandlerAdapter and override the createServletExternalContext function.

    Basically you use ServletExternalContext.getSessionMap() to access a SharedAttributeMap and register your properties.

    As you have access to the HttpServletRequest and HttpServletResponse objects, this method can act petty much like a HandlerInterceptorAdapter.postHandle function.

    See an example below.

    I left out how to use generic way to reuse the same code for a HandlerInterceptor for the MVC and this object but it’s easy to code, by implementing HandlerInterceptor.


    MyFlowHandlerAdapter :

    package my.package;
    public class MyFlowHandlerAdapter extends FlowHandlerAdapter {
    
        @Override
        protected ServletExternalContext createServletExternalContext(
                HttpServletRequest request,
                HttpServletResponse response) {
    
            ServletExternalContext context = 
                super.createServletExternalContext(request,response);
    
            context.getSessionMap().put("myproperty", "myvalue");
    
            return context;
        }
    }
    

    You have the FlowHandlerAdapter object defined in you webflow-context.xml file like that :

    <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
        <property name="flowExecutor" ref="flowExecutor"/>
    </bean>
    

    Just replace it with :

    <bean class="my.package.MyFlowHandlerAdapter">
        <property name="flowExecutor" ref="flowExecutor"/>
    </bean>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

HandlerInterceptor s in Spring can now be configured to be invoked only on certain
Have deployed numerous report parts which reference the same view however one of them
have been trying couple of hours now to make my iphone app universal. The
Have some code: using (var ctx = new testDataContext()) { var options = new
Have a n-tire web application and search often times out after 30 secs. How
I am working on web performance and I have to communicate with a remote
**Have it working now. I forgot to populate the Array List. How embarrassing. I'm
Have a web service that implements REST (sort of) , Client request is made
Have some runtime defined schedule for one week, for example: <schedule> <s day=Monday, time=1:00:00></s>
Have a numeric nvarchar values with some extra-symbols For example 1/2, 9/6, 14A They

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.