0
votes

I have a JSF app, with a login

<h:commandButton id="btnLoginId" value="Login" action="#{UserLoginMB.login}" styleClass="loginPanelBtn"></h:commandButton>

which works and sens a "correct" result to the managedBean,

        public String login() {
            // ...
            return "correct";
        }

after that, the return says :

Impossible de trouver un cas de navigation correspondant depuis l’ID de vue «/home/index.xhtml» pour l’action «#{UserLoginMB.login}» avec le résultat «correct».

Which means Impossible to find a navigation way correspending to ID of view home/index.xhtml for action (Bean.login) with result "correct"

while I have setup the Faces config to redirect to /home/backend/index.xhtml in case of a success result (correct return),

    <!-- navigation-rule for login.xhtml -->
    <navigation-rule>
        <from-view-id>/home/index.xhtml</from-view-id>
        <!-- navigation-case for method login() -->
        <navigation-case>
            <from-action>#{userLoginMB.login}</from-action>
            <from-outcome>correct</from-outcome>
            <to-view-id>/home/backend/index.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>

and in apache log :

AVERTISSEMENT: JSF1064 : Impossible de localiser ou de servir une ressource, /home/correct.xhtml.

Which means Impossible to localize the ressource /home/correct.xhtml while I never used such a ressource.

1

1 Answers

2
votes

That can happen if <from-view-id> or <from-action> didn't exactly match (they are case sensitive!) and thus JSF can't find the associated <navigation-case> with the desired outcome. Then JSF will default to implicit navigation, which means that the returned string will be treated as <to-view-id>.

So, in case of e.g.

public String login() {
    // ...
    return "correct";
}

and a <navigation-case> could not be found, then JSF will implicitly navigate to correct.xhtml in the same folder as the current view. This feature is new since JSF 2.0 and it saves the developer from writing all the XML boilerplate full of navigation cases. In your particular case, instead of using a navigation case, you could also just return "backend/index".

public String login() {
    // ...
    return "backend/index";
}

See also: