Search code examples
springspring-securityspring-webflowspring-el

Secured tag of Spring Web Flow: How to pass Flow scope parameter to a Spring bean method?


I'm securing Spring Web Flow states with Spring security. In the secured tag I'm calling a method of a Spring bean and trying to pass a Flow scope parameter to it. Everything works fine except the passing of the Flow scope parameter - null is passed.

This is the snippet from the Web Flow xml:

<action-state id="securedAction">
    <secured attributes="@myAction.accessGranted(#flowScope.parameter)" />
    ...
    ...
</action-state>

How to pass the Flow scope parameter?


Solution

  • I have found an answer to my own question - instead of trying to pass the flow scoped parameter from the flow via the Java method parameters, it can be fetched via org.springframework.webflow.execution.RequestContextHolder in the called method:

    RequestContextHolder.getRequestContext().getFlowScope().get("parameter");
    

    P.S.:
    If you want to set a flow scoped parameter use

    RequestContextHolder.getRequestContext().getFlowScope().put("parameter", myParameterObject);