The managed bean involved.
@Named
@ViewScoped
public class Bean implements Serializable {
public Bean() {}
private static final long serialVersionUID = 1L;
public String navigate() {
System.out.println("navigate() invoked.");
// This method carries some logic here.
return "/ContextPath/location/page.xhtml?faces-redirect=true";
}
}
Now, using a command component with action
is expected to redirect to a said resource.
<h:form>
<p:commandButton value="Submit" action="#{bean.navigate}"/>
</h:form>
This is however, always untrue no matter ajax
is set to false
or using another command component like <p|h:commandLink>
. The action method is invoked as usual in either case but it does not perform navigation.
Replacing the action method directly with a navigation case outcome such as,
<p:commandButton value="Submit"
action="/ContextPath/location/page.xhtml?faces-redirect=true"/>
does not make any difference.
Is this really expected?
This is a kind of very basic question but I do not find at least direct answers in other already asked questions.
Using Mojarra 2.2.12 and PrimeFaces 5.2 (community bundle).
` and `
` invoke the action method in the bean as usual but they do not perform navigation. I see no warning on the server log. This also does not go : ` `. This however, worked on a test project. There should be a hidden problem somewhere in the real application itself where no warning is raised even though a navigation case outcome is deliberately given wrong in a single test XHTML file.
– Tiny Oct 04 '15 at 14:45