Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 2 使用PhaseListener截取渲染阶段_Jsf 2_Phaselistener - Fatal编程技术网

Jsf 2 使用PhaseListener截取渲染阶段

Jsf 2 使用PhaseListener截取渲染阶段,jsf-2,phaselistener,Jsf 2,Phaselistener,我在一个支持bean中调用一个函数,但是在呈现jsf页面之前,我需要执行一些依赖于将呈现的jsf页面的操作(该页面从一个调用更改为另一个调用) 在渲染页面之前,我需要截取url的名称,因为我需要执行操作并将结果存储在会话中 所以我想使用PhaseListener来获取URL,而不是导航案例的名称 例如:函数“execute”返回“ivIndex”,但我需要得到“/zone/iv/index.xhtml” 我怎么能做到 方法: public String execute(){ return n

我在一个支持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>

*
伊文迪克斯
/zone/iv/index.xhtml
您可以使用

FacesContext.getCurrentInstance().getViewRoot().getViewId();