aspose file tools*
The moose likes JSF and the fly likes How to setup navigation rules correctly? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How to setup navigation rules correctly?" Watch "How to setup navigation rules correctly?" New topic
Author

How to setup navigation rules correctly?

Don Blodgett
Ranch Hand

Joined: Jan 09, 2006
Posts: 61
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?

I have a directory structure that looks like this



I appreciate any help on this, thanks.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16142
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Don Blodgett
Ranch Hand

Joined: Jan 09, 2006
Posts: 61
Thanks for your reply Tim. I changed the xhtml to jsf, but unfortunately the same problem occurs. Also I think that I should point out that the application I am working on, all the URLs that are sent by the client end with xhtml. Not entirely sure why that is, but it renders the pages correctly, including all of the jsf processed tags. On the other hand, if the pages are requested ending with jsf, the resources (css, images, javascript) produce 404 errors. In both cases, if I attempt to access restricted pages it correctly redirects to the signin page, unless the current session already has an authorized principal, which is then correctly allowing access to the page. As for the URLs ending with xhtml, that is not specified, instead only the view Id is provided, for example:



Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16142
    
  21

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).
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to setup navigation rules correctly?