This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
When the user enters their login information on the signin page, based on their permission would determine if they are sent to the admin page or the content page. When a user that doesn't have admin permission logs in they are successfully directed to the content page, but when an admin user logs in the signin page is refreshed instead of directing them to the admin page. If the admin user manually goes to the admin page by typing the path directly in the address bar, after signon, the page is displayed correctly.
The signon method that is called from the signin page returns either "admin" or "content".
I thought that it may be an issue with the directory structure. So I created a navigation-rule in faces-config.xml that looks like this.
Unfortunately that did not solve the problem. I was wondering what I am missing here?
You are confusing the resource name (.xhtml) with the URI (.jsf). One is a "filesystem path" within the WAR, the other is part of an identifying string (URL) sent by a client to a server which parses it and determines what content to return.
JSF's navigation rules have to target URIs, not resources.
An IDE is no substitute for an Intelligent Developer.
Joined: Jan 09, 2006
In theory, .xhtml is just as valid a JSF pattern key as ".jsf" is, but I'd be hesitant to use it. Partly because I've no assurance that there couldn't be internal confusion, partly because I'm virtually certain that low-grade maintenance programmers would get confused (to most of them, anything with slashes in it is a filesystem path, and it goes downhill from there).
I couldn't actually see what might be wrong, but selecting one of the following two options can make your link tag more reliable:
1. Change the outcome to "/comment". That ensures that if a URL is synthesized from it that relative locations won't confuse things
2. Define "comment" as a "from-outcome" name in a faces-config rule. That allows you to keep the actual navigation abstracted from the page content (and also allows dealing with absolute/relative View paths).