0

The following page is the last page in my flow scope:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:h="http://xmlns.jcp.org/jsf/html">
<head>
    <title>Last page in the flow</title>
</head>
<body>
<h1>Registration completed!</h1>
<p>value: #{flowScope.name}</p>
<p>value: #{flowScope.surname}</p>
<h:form prependId="false">
    <p><h:commandButton id="back" value="back" action="signup2" /></p>
    <p><h:commandButton id="home" value="home" action="homePage">
        <f:setPropertyActionListener value="#{flowScope.name}"
                                     target="#{mainController.name}"/>
    </h:commandButton></p>
</h:form>
</body>
</html>

I would like to pass the name to my mainController. This only works if mainController is session scoped, but not if it is request scoped ? Why ?

Regards Roger

rogergl
  • 3,501
  • 2
  • 30
  • 49

1 Answers1

0

It simple

@RequestScoped - Bean lives as long as the HTTP request-response lives. It get created upon a HTTP request and get destroyed when the HTTP response associated with the HTTP request is finished.

In your case you need longer scope: @ViewScoped (if it on the same page), @SessionScoped or @ApplicationScoped for displaying data from previous page(s).

Based on definition, data in @RequestScoped mainController is stored util response is finished and destroyed after that.

Vasil Lukach
  • 3,658
  • 3
  • 31
  • 40
  • But it works if I do this outside a flow and I do not understand why a flow changes this behavior. – rogergl Apr 14 '14 at 19:03
  • See [this ansver](http://stackoverflow.com/questions/19322364/what-is-the-default-managed-bean-scope-in-a-jsf-2-application-in-netbeans). It contains some additional info. – Vasil Lukach Apr 14 '14 at 20:32