Question

I am trying to navigate to an xhtml page in a static web project. My original context is a dynamic web project with icefaces 3.3. It redirects to the below path with .faces even when I specify .xhtml as outcome in the to-view-id. Is there any way to make it redirect to .xhtml instead?

http://localhost:9080/staticWebRoot/logout.faces

faces-navigation.xml

<navigation-rule>
    <from-view-id>*</from-view-id>
    <navigation-case>
    <from-outcome>logout</from-outcome>
    <to-view-id>/../../staticWebRoot/logout.xhtml</to-view-id>
    <redirect/>     
    </navigation-case>
</navigation-rule>
Was it helpful?

Solution

You can and should not use navigation rules for non-JSF resources. JSF assumes that all to-view-ids are real JSF views in the current webapp (otherwise, they wouldn't be called "view IDs" in first place).

Just use ExternalContext#redirect().

public void redirect() throws IOException {
    // ... 
    FacesContext.getCurrentInstance().getExternalContext().redirect("/staticWebRoot/logout.xhtml");
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top