spring-webflow-2

spring webflow requestScope variables not visible in view


given

<view-state id="bstate" model="foo">
<on-entry>
    <evaluate expression="service.createPerson(22,'Adam', 'Hayek')"
            result="viewScope.person"></evaluate>
</on-entry>
...
</view-state>

in jsp view I can successfully get person by

${person}

but when I put into requestScope instead of viewScope

${person} is no longer available in jsp


Solution

  • Spring webflow follows POST-REDIRECT-GET approach for every request. 
    i.e., initial request is split into 2 requests - 
    POST processing and then REDIRECT-GET (render view)
    
    In <on-entry>, action happens in first request and so request 
    attribute will not survive when view is rendered.
    
    In <on-render>, whole action happens in second request and so 
    request attribute will survive when view is rendered.
    
    So put it in <on-render> instead of <on-entry> for request scope. 
    View scope value survives from entry to exit of view.