Question

I am calling a function in a backing bean, but before rendering jsf page, I need to make some operations that depend on the jsf page that will render (this page changes from one call to another).

I need to intercept the name of the url, before renderize page, because I need to perform operations and store the result in session.

So I want to use a PhaseListener to get the URL, and not the name of navigation case.

Eg: The function 'execute' returns 'ivIndex' but I need to get '/zone/iv/index.xhtml'.

How I can do this?

method:

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>
Was it helpful?

Solution

You can use

FacesContext.getCurrentInstance().getViewRoot().getViewId();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top