Search code examples
jsf-2.2omnifaces

Omnifaces extensionless URLs and h:link


According to http://showcase.omnifaces.org/facesviews/ExtensionlessURLs by default, all URLs generated by ViewHandler.getActionURL(FacesContext, String), which is used by among others

<h:form>, <h:link>, <h:button> 

and all extended tags, will also be extensionless.

I try using this by putting Facelets source files into /WEB-INF/faces-views directory.

I typed /context/entries in the browser and I got the page in /WEB-INF/faces-views/entries.xhtml. But when I used this in my facelet page:

<h:link outcome="entries">Entries</h:link>

The url resulted is /context/WEB-INF/faces-views/entries.xhtml which is not the desirable result. What went wrong?

I am using Mojara 2.2.12 and Omnifaces 2.6.9 and my faces servlet mapping is *.jsf.


Solution

  • There was a small mistake in FacesViews of specifically 2.6.9 which is fixed in 2.7-SNAPSHOT. While working on getting FacesViews to support folders with periods in names such as /foo.bar/baz, I have accidentally committed a part of the fix into 3.x only instead of into 2.x. That explains why it works just fine in 3.1, as demonstrated by the "viewsdemo" showcase. My mistake, this just proves again that I'm a human and not a machine.

    There are a few options to get around this:

    1. Downgrade to 2.6.8.
    2. Or, migrate to 3.1.
    3. Or, keep 2.6.9 and use the "Minimal configuration" approach of a single web.xml context parameter instead of "Zero configuration" approach of placing files in /WEB-INF/faces-views.