以下页面是我的流程范围中的最后一页:
<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>
我想将名称传递给我的mainController。这仅在mainController是会话作用域时有效,但如果是请求作用域则不行吗?为什么?
此致 罗杰
答案 0 :(得分:0)
很简单
@RequestScoped - 只要HTTP请求响应存在,Bean就会存在。它在HTTP请求时创建,并在与HTTP请求关联的HTTP响应完成时被销毁。
在您的情况下,您需要更长的范围:@ViewScoped(如果它在同一页面上),@ SessionScoped或@ApplicationScoped用于显示上一页的数据。
根据定义,@RequestScoped
mainController
中的数据被存储,工具响应在此之后完成并销毁。