[英]Using an PhaseListener to intercept the rendering phase
我在后备Bean中调用一个函数,但是在呈现jsf页面之前,我需要进行一些依赖于将呈现的jsf页面的操作(此页面从一个调用变为另一个调用)。
在渲染页面之前,我需要拦截url的名称,因为我需要执行操作并将结果存储在会话中。
因此,我想使用PhaseListener来获取URL,而不是导航用例的名称。
例如:函数' execute '返回' ivIndex ',但我需要获取' /zone/iv/index.xhtml '。
我该怎么做?
方法:
public String execute(){
return nameUrl(); // return name of a navigation rule, per example : ivIndex
faces-config.xml
<navigation-rule>
<from-view-id>*</from-view-id>
<navigation-case>
<from-outcome>ivIndex</from-outcome>
<to-view-id>/zone/iv/index.xhtml</to-view-id>
</navigation-case>
您可以使用
FacesContext.getCurrentInstance().getViewRoot().getViewId();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.