our company app is configured so that when a user clicks the login button from the front page, and index.html file redirects the user to the main page of the authenticated/authorized area of our app, index.xhmtl (rendered as index.jsf), but since the user hasn't logged in yet, they are shown the login page: login.xhml (rendered as login.jsf), BUT in the browser URI field it shows:
examples.com/index.jsf
my problem was trying to get a navigation rule working, so that if during the authentication/login process, if the app found out that the user needed to change his password, he would be redirected to /newPassword.xhtml
but it wasn't working and i was getting this error:
"Unable to find matching navigation case with from-view-id login.xhtml..."
i found out eventually that the from-view-id needed to be the page that was shown in the browser URI field, namely index.xhtml, and not login.xhtml.
here are the relevant code and configurations.
#############
/login.xhtml
#############
<p:commandButton value="Login" update="checkPassword" action="#{loginBean.login}" ... />
#############
LoginBean.java
#############
...
private String changePass = "newPassword";
...
public String login() {
...
if(mustChangePassword) {
...
return changePass;
}
}
...
#############
WEB-INF/faces-config.xml
#############
<faces-config ... >
<navigation-rule>
<from-view-id>/index.xhtml</from-view-id>
<navigation-case>
<from-action>#{loginBean.login()}</from-action>
<from-outcome>newPassword</from-outcome>
<to-view-id>/newPassword.xhtml</to-view-id>
<redirect />
</navigation-case>
...
</navigation-rule>
</faces-config>
IT, computer and programming tutorials and tips that i couldnt find anywhere else using google, from my daily work as a Senior Developer of solutions using Java and Linux.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment