1
Redirect is a specific term.
You can redirect or forward:
Forward
Forwarding means taking the user to another page within the same context without a new request being made.
This way, the URL in the browser’s address bar does not change. Continue with the address of the old page.
Ex:
@ManagedBean
public class TesteMB {
public String encaminha() {
return "pagina";
}
}
Redirect
Redirecting means making a new request. Redirecting can point to out-of-context pages (www.uol.com.br, for example).
When redirecting the address bar URL is changed, it is updated to the address of the page in question.
Ex:
@ManagedBean
public class TesteMB {
public String redireciona() {
return "pagina?faces-redirect=true";
}
}
Note that in neither case was it necessary to include the extension of pagina
.
This is optional.
XHTML
In XHTML use the attribute action
inside the desired tag.
Ex:
<p:commandButton action="#{testeMB.encaminha}" />
<p:commandButton action="#{testeMB.redirectiona}" />
See help: https://stackoverflow.com/questions/4032825/how-to-make-a-redirection-in-jsf
– Bruno César