This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes JSF and the fly likes JSF navigation with PrettyFaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF navigation with PrettyFaces" Watch "JSF navigation with PrettyFaces" New topic
Author

JSF navigation with PrettyFaces

Andrew Dambrosio
Greenhorn

Joined: Jul 04, 2011
Posts: 11
I have a JSF 2.0 web app that stores every page in a database table. The table includes the "pretty" URL for the page.
What I would like to do is, if you enter the URL "www.test.com/com/aboutus.html" This should access the actual page of "www.test.com/faces/pages.xhtml?url=%2Fcom%2Faboutus.html"

Basically, any of my pages need to access the pages.xhtml file, passing in the pretty URL and displaying the pretty URL in the browser navigation bar.
I think I should use Pretty Faces to do this, but I'm not sure how to set it up.
Does anyone know?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15661
    
  15

I am a little confused about what you are asking.

You are using a sample URL with "html" in it, and that ordinarily isn't going to be a JSF target. Incidentally, JSF navigation can ONLY go to JSF targets, not to general (non-JSF) URLs such as vanilla HTML pages.

A URL would also not normally have ".xthml" in it, because xhtml's are resources and the JSF/Facelets resource resolution mechanism doesn't accept direct resource references, it accepts JSF-mapped URLs, which are then used as the basis for locating resources based on the rules defined in web.xml. So, in other words, "/dir1/page2.jsf" -> "/dir1/page2.xhtml".


Customer surveys are for companies who didn't pay proper attention to begin with.
Andrew Dambrosio
Greenhorn

Joined: Jul 04, 2011
Posts: 11
My JSF pages need to appear as HTML pages. I've figured out that using PrettyFaces is my best option.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15661
    
  15

JSF pages almost always appear as HTML pages. JSF contains an abstract View rendering system that that takes View Templates (xhtml), binds JSF Model objects (backing beans) to them, then applies a plugin-in rendering engine to the resulting sets to produce output. By default a built-in engine that generates HTML is used.

This is not the same thing as brute-force raw HTML. JSF does not support HTML for navigation purposes, only JSF Views. Any moving to or from raw HTML web pages has to be done manually.
 
Don't get me started about those stupid light bulbs.
 
subject: JSF navigation with PrettyFaces
 
Similar Threads
Navigation Question
JSF NewBie
struts url problem
Can we Access FacesContext outside FacesServlet
<to-view-id> Element