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.
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?
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".
An IDE is no substitute for an Intelligent Developer.
Joined: Jul 04, 2011
My JSF pages need to appear as HTML pages. I've figured out that using PrettyFaces is my best option.
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.