I am fairly new to JSF, but thought that I had this right, however I am not getting the navigation I expect...

When I get an error for a duplicate username, I want to be sent back to my registration form and have an error message shows.

faces-config:
============

    <navigation-rule>
        <from-view-id>/views/registration.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>success</from-outcome>
            <to-view-id>/views/secure/index.xhtml</to-view-id>
            <redirect/>
        </navigation-case>
        <navigation-case>
            <from-outcome>cancel</from-outcome>
            <to-view-id>/views/center.xhtml</to-view-id>
            <redirect/>
        </navigation-case>
        <navigation-case>
            <from-outcome>duplicateUsername</from-outcome>
            <to-view-id>/views/registration.xhtml</to-view-id>
            <redirect/>
        </navigation-case>
    </navigation-rule>





Here is the UserBackingBean method:
============================

    public String createUser(){
        log.info("createUser()");

        FacesContext context = FacesContext.getCurrentInstance();

        try{
            userManager.createUser(getUser());
        } catch(Exception e){
            log.error("Duplicate user name. Username already exists");
            e.printStackTrace();
            String failureMessage = "Duplicate user name. Username already exists";
            FacesContext.getCurrentInstance()
                    .addMessage(null,
                            new FacesMessage(
                                    FacesMessage.SEVERITY_ERROR,
                                    failureMessage,
                                    failureMessage));

            return "duplicateUsername";
        }
        return "success";
    }


When I get this error, I still get sent to /views/secure/index.xhtml, same as if I succeeded...


--

Thanks

DJ MICK
http://www.djmick.com
http://www.myspace.com/mickknutson

Reply via email to