4

I have understood the meaning of jsf 2.0 context parameters "javax.faces.DEFAULT_SUFFIX" and "javax.faces.FACELETS_VIEW_MAPPINGS" with some examples. But I'm not clear about parameter "javax.faces.FACELETS_SUFFIX".

According to the documentation:

javax.faces.FACELETS_SUFFIX": Allow the web application to define an alternate suffix for > Facelet based XHTML pages containing JSF content. If this init parameter is not specified, the default value is taken from the value of the constant DEFAULT_FACELETS_SUFFIX which is "xhtml".

So If I want to change jsf file extension from xhtml to xml, I have below settings:

<context-param>
    <param-name>javax.faces.FACELETS_SUFFIX</param-name>
    <param-value>.xml</param-value>
</context-param>

But when I access the page in web browser, I get a HTTP 404 error.

If I change the settings as below:

<context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.xml</param-value>
</context-param>
<context-param>
    <param-name>javax.faces.FACELETS_VIEW_MAPPINGS</param-name>
    <param-value>*.xml</param-value>
</context-param>

Then when I access the page in web browser, it works.

Can someone explain me what is the real meanning of parameter "javax.faces.FACELETS_SUFFIX"?

Hui Zhou
  • 45
  • 5

1 Answers1

3

It has to go as <context-param> in webapp's web.xml file.

E.g., when you want to change it from .xhtml to .xml:

<context-param>
    <param-name>javax.faces.FACELETS_SUFFIX</param-name>
    <param-value>.xml</param-value>
</context-param>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • I tried with Mojarra 2.1.3 and IceFaces 2.0 and it didn't work. Only setting the two params as Hui Zhou did worked for me. This seems like a bug though (don't know where exactly, probably Mojarra). – hugri Nov 03 '11 at 14:57