I am using PrimeFaces with JSF2. I am trying to authenticate user by sending login and password as an Ajax request. And in the action method of the backing bean, I am trying to validate user and redirect to a new view if the validation succeeds.
Is this possible while using primefaces?
Because I think with primefaces' p:commandButton
, I can only either have ajax behavior or the navigation.
Yes, just send a redirect instead of a (default) forward as outcome. The <navigation-case>
-less JSF 2.0 way would be appending ?faces-redirect=true
to the outcome string in the action method.
E.g.
public String login() {
// ...
return "home?faces-redirect=true";
}