jsr372-experts@javaserverfaces-spec-public.java.net

[jsr372-experts] 1099-ViewsInDedicatedFolder

From: arjan tijms <arjan.tijms_at_gmail.com>
Date: Wed, 22 Oct 2014 00:03:31 +0200

Hi,

One of the small hurdles that (new) JSF users have to overcome is that
of mapping the Faces Servlet. In JSF 2.0 this was simplified by using
a number of default mappings, but unfortunately none of these are
entirely optimal.

The trouble is that these default mappings are *.jsf, *.faces and
/faces/*, while the actual file is nearly always *.xhtml. There's thus
a disconnect between the requested extension and the file extension.
Compare this to JSP where a request for /foo.jsp maps to a file
/foo.jsp. Even though there's arguably more mapping magic going on
behind the scenes, this has worked since day 1 of JSP.

The best-practice advice (IMHO, but I think widely shared) is to
always map the Faces Servlet right away to *.xhtml. If something
should nearly always been done by the user and only rarely not be
done, then I think it's a good candidate to be considered for
simplification.

An optimal solution going forward and absolutely trivial to implement
is just adding *.xhtml to the default mappings. However, this may have
backwards compatibility issues and has therefor been rejected before.

Another solution is to use the recently introduced switch, that uses a
2.3 faces-config and/or 4.0 web.xml for possibly incompatible EL
resolving behavior, to switch between having *.xhtml as a default
mapping or not. Meaning a 2.3 faces-config.xml causes a mapping on
*.xhtml by default, any lower versioned or no faces-config keeps the
current mappings.

Yet another solution, that incidentally also ties in with the
extensionless URL mappings that were discussed on this list a while
back, is to have a dedicated folder from which views are loaded.

This is not entirely unlike the dedicated folders for contracts and
composites that already exist today. Views in that folder would be by
definition JSF views, so the runtime can safely map them, with or
without extension. A while back I created
https://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-1099 for this
and implemented it in OmniFaces.

Hope that we can have some discussion on this topic here.

Kind regards,
Arjan