我们希望将一个变量从一个页面的请求范围中的支持bean作为查询字符串参数传递给下一页面的视图范围中的其他支持bean.
我尝试使用@ManagedParam
,但找不到此签名.
有没有办法做到这一点?
你可能想要使用@ManagedProperty
.这在视图范围bean上无法用于设置请求参数,因为视图范围的范围比请求范围更广.
传递请求参数和对它们调用操作的规范JSF2方式如下所示:
view.xhtml
视图:
<h:link value="Edit" outcome="edit">
<f:param name="id" value="#{item.id}" />
</h:link>
Run Code Online (Sandbox Code Playgroud)
edit.xhtml
视图:
<f:metadata>
<f:viewParam name="id" value="#{edit.id}" />
<!-- You would normally also convert/validate it here. -->
<f:event type="preRenderView" listener="#{edit.init}" />
</f:metadata>
Run Code Online (Sandbox Code Playgroud)
Edit
支持豆:
@ManagedBean
@ViewScoped
public class Edit {
private Long id;
public void init() {
// This method will be invoked after the view parameter is set.
}
// ...
}
Run Code Online (Sandbox Code Playgroud)