I have a system with a form where you can edit or remove items. There is a link to redirect another page.
What form can I redirect a page to in JSF?
Redirect is a specific term. You can redirect or forward :
Forwarding means taking the user to another page within the same context without a new request being made.
That 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 means making a new request. The redirect can point to out-of-context pages (www.uol.com, for example). Redirecting the address bar URL is changed and 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 extent of pagina
.
This is optional.
In XHTML use the action
attribute within the tag you want.
Ex:
<p:commandButton action="#{testeMB.encaminha}" />
<p:commandButton action="#{testeMB.redirectiona}" />