Tuesday, December 23, 2008

JSF page based on Seam example not rendered

If you’re a JSF newbie (like me), and you’re using Seam, you might be tempted to take one of the examples and hack away at it. For instance, in the booking example, the first page is called home.xhtml. After you type up some tags, you want it to run, so you point your browser at:
What you’ll find is not a JSF rendered page, but your JSF tag source! Then you think that you’ve misconfigured something, so you look over everything. But what’s really going on is that the Seam example isn’t configured to render that page, instead you should go to:
That will render the home.xhtml as JSF. Look in your war file’s WEB-INF/web.xml, and find this bit of code:
    <servlet-name>Faces Servlet</servlet-name>
This means that the Faces Servlet logic executes against URLs that end with .seam. However, being a newbie, I’m not quite sure what maps that against the .xhtml file, unless it’s this previous entry:
Also being a newbie, I’m not sure what I should do to configure things so that it’s impossible for a user to download my JSF code…
Anyhow, what makes this all work by default is the file index.html, which is what will load when you visit:
and that contains the following:
    <meta http-equiv="Refresh" content="0; URL=home.seam">
which naturally redirects you to the appropriate URL to start rendering your JSF/Seam application.
Thanks to anyone who points out the answers to the above mysteries (that are probably in the docs somewhere…)

No comments:

Post a Comment