Si vous réaliser une page nommée page1.xhtml avec un bouton vers page2.xhtml, le navigateur affichera bien sûr cette page2 mais l'URL affichée par le navigateur sera toujours page1.xhtml. Ce comportement par défaut de jsf est nommé "page forward".
Si vous voulez modifier le comportement pour que l'URL soit actualisé il faut utiliser l'option "faces-redirect=true" pour faire du "page redirect".
Ainsi, dans notre exemple, ce serait :
La page page1.xhtml :
<?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"> <h:head> <title>Project Information</title> </h:head> <h:body> Page1 <h:form id="projectForm"> <h:commandButton value="Go to page 2" action="page2?faces-redirect=true"/> </h:form> </h:body> </html>
La page page2.xhtml:
<?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"> <h:head> <title>Project Information</title> </h:head> <h:body> Page2 </h:body> </html>