File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes xHtml and Facelets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "xHtml and Facelets" Watch "xHtml and Facelets" New topic
Author

xHtml and Facelets

Justin Rundle
Ranch Hand

Joined: Mar 26, 2008
Posts: 123

Hi there, quick newbie question. I recently downloaded the ICEFaces 2.0.0 alpha distributions and was looking at the example apps. Some of the files are as follows:

web.xml


index.jsp


So my questions is that when we start the app and navigate to the app, the app will automatically redirect to index.jsp (as defined in the web.xml welcome-file-list) and then the index.jsp page will redirect to showcase.jsf. HOWEVER there is no showcase.jsf file within the project, only showcase.xhtml.

showcase.xhtml:


How does the facelets view handler know to map files with *.jsf extension to *.xhtml files?

Thanks, any feedback will be appreciated.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15954
    
  19



Like a lot of people, however, you're mistaking a URL for a file. You shouldn't have any "files" in your project whose names end with ".jsf". However, if you're configured with the URL pattern "*.jsf", incoming URLs with ".jsf" at the end of them will be routed to the Faces Servlet, which will then parse out the URL and locate the corresponding JSP or xhtml file.


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

Joined: Mar 26, 2008
Posts: 123

So in the example does the Faces Servlet parse the "showcase.jsf" into "showcase.xhtml"?

And more so what if your file didnt end in *.xhtml?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15954
    
  19

Justin Rundle wrote:So in the example does the Faces Servlet parse the "showcase.jsf" into "showcase.xhtml"?

And more so what if your file didnt end in *.xhtml?


Well, technically, parsing is only part of what it does. The FacesServlet parses, then transforms, and finally resolves using the transformed name as a WAR resource pathname.

Truthfully, I haven't ever dug down that deep, but if the file didn't end with ".xhtm", then the attempt to open "showcase.xhtml" would fail, resulting in a 404 (Resource Not Found) error. Although for all I actually know, it first checks for a "showcase.jsp" file as an alternative before giving up. I've never checked.
 
wood burning stoves
 
subject: xHtml and Facelets
 
Similar Threads
Primefaces setup causing problems JSF 2.0
*.faces suffix mapping
Facelets custom tag not recognized ?
Error JSF 2.1: java.io.FileNotFoundException:*/*.xhtml Not Found in ExternalContext
JSF, Facelets losing context after reload