springspring-webflow-2

Access flashattribute in Springflow


Added value to redirectAttrs.addFlashAttribute("some", value); and then redirect to Springflow

How to access flashattribute some in Springflow?

<on-start>
 <evaluate expression="do.Action(???)" result="flowScope.someobject" />
</on-start>

Solution

  • try:

    <evaluate expression="webFlowUtils.getFlashAttribute(externalContext, 'some')"/>
    

    with:

    @Component
    public final class WebFlowUtils {
    
        public Object getFlashAttribute(ExternalContext context, String attributeName) {
            Map<String, ?> flashMap = RequestContextUtils.getInputFlashMap((HttpServletRequest) context.getNativeRequest());
            return flashMap != null ? flashMap.get(attributeName) : null;
        }
    }