I am trying to forward a page in my managed bean with the commandbutton:
<h:commandButton action="#{bean.action}" value="Go to another page" />
The following line:
public void action() throws IOException {
FacesContext.getCurrentInstance().getExternalContext().redirect("another.xhtml");
}
redirects the page, not forwards. I have seen a similar question to this and tried the given solution:
public void action() throws IOException {
FacesContext.getCurrentInstance().getExternalContext().dispatch("another.xhtml");
}
But I get the following error:
Index: 0, Size: 0
So how can I forward to a page from a managed bean?