I want to navigate to other page when I fill a form and I send the data that I entered. I have declare the navigation-rules but it doesn't work and I don't know why.
In my faces-config.xml I've added the navigation-rules:
<managed-bean> <managed-bean-name>usuario</managed-bean-name> <managed-bean-class>com.miApp.UserBean</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> </managed-bean> <navigation-rule> <from-view-id>/SolicitarAlta.xhtml</from-view-id> <navigation-case> <from-action>#{usuario.registrar}</from-action> <from-outcome>correcto</from-outcome> <to-view-id>/results/correcto.jsp</to-view-id> </navigation-case> </navigation-rule>
public String registrar() { if(dni==null || nombre==null || apellidos==null || ocupacion==null || mail==null || tlf==null || password==null) return "campos-obligatorios"; if ((mail.trim().length() < 3) || (mail.indexOf("@") == -1)) return "mail-incorrecto"; else if(tlf.length()!=9) return "telefono-incorrecto"; else if(dni.length()!=8) {return "dni-incorrecto";} return "correcto"; }
<h:commandButton type="submit" value="Enviar" action="#{usuario.registrar}"/>the method registrar is executed and I know that this method returns the string "correcto" but ... This doesn't redirect me to the page correcto.jsp
Rodosa,
Pure jsf things again. Please ask in the appropriate forum.