0

I have the following navigation case in my faces-config.xml:

<navigation-rule>
    <from-view-id>*</from-view-id>
    <navigation-case>
        <from-outcome>CadastroAutorizado</from-outcome><to-view-id>/paginas/cadastro/clientes/cadastroAutorizado.jsf</to-view-id>
    </navigation-case>
</navigation-rule>

In some buttons i want to call an actionListener that do some validations and then call a method that programmatically redirects to some page, using this method:

FacesContext.getCurrentInstance().getExternalContext().redirect("CadastroAutorizado");

What i want is to redirect to the page configured in the navigation case:

/paginas/cadastro/clientes/cadastroAutorizado.jsf

How to do it?

-----------EDIT-----------

This is the button where i call the actionListener that reirects:

<p:commandButton id="botaoRetornar" global="false" value="Retornar" update="formPrincipalTemplate" actionListener="#{mbName['acaoRetornar']}" />

In the method, i want to execute some validations, and in case that validation fails, it must stay in the same page and show a message using primefaces growl component. How can i do it using the action attribute instead of actionListener?

Mateus Viccari
  • 7,389
  • 14
  • 65
  • 101
  • Use `action` instead of `actionListener` (see [here](http://stackoverflow.com/q/3909267/1065197) for an explanation). Assuming you're currently in */paginas/cadastro/clientes/*, you can redirect to *cadastroAutorizado.jsf* (or the extension you're using to evaluate your views with Faces Servlet) or by returning `cadastroAutorizado?faces-redirect=true` in your action method. – Luiggi Mendoza Jun 03 '13 at 14:22
  • I updated the question, about your answer, i have another question about the action attribute. – Mateus Viccari Jun 03 '13 at 14:46
  • This can be accomplished using `action`, not `actionListener`. Please refer to the link I've provided in my previous comment to understand their difference and the usage of each one. – Luiggi Mendoza Jun 03 '13 at 15:12

0 Answers0