I must set explicit navigation in my web application (Java 8 + Primefaces 6). I don't know these technologies very well but I would like to set for every xhtml page a general name to view in the url.
So I created a page test.xhtml:
<h:form id="formId">
<p:inputText...
<p:commandButton id="btn"
value="test"
action="#{myBeanViewScoped.test()}" />
</h:form>
The method test return an xhtml page if there are not errors. If I add as suffix in the return statement the code:
return "/calledPage.xhtml?faces-redirect=true"
works correctly. I read some articles about this and I tried to remove the suffix "?faces-redirect=true" and to add in my faces-config.xml this code:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
<application>
<locale-config>
<default-locale>en</default-locale>
</locale-config>
</application>
<navigation-rule>
<display-name>test</display-name>
<from-view-id>/test.html</from-view-id>
<description>test</description>
<navigation-case>
<display-name>authenticated</display-name>
<description>authenticated</description>
<from-action>#{myBeanViewScoped.test}</from-action>
<from-outcome>/calledPage.xhtml</from-outcome>
<to-view-id>/calledPage.xhtml</to-view-id>
<redirect />
</navigation-case>
</navigation-rule>
</faces-config>
The application does not generate errors, but I see in the URL always test.xhtml and not "authenticated". Where is my fault?
Thanks.