Arjan-
I agree that the mapping of the Faces Servlet could be a point of
uncertainty for new JSF users. I also agree that promoting an easier path
for this mapping would make it even easier to use JSF as a newcomer.
I like the default mapping of *.xhtml for >= 2.3. In my opinion, this
could just become the default, and users should always have the ability to
override it by specifying a different mapping in the XML, if needed.
I am also on-board with your idea of providing a new option to place the
JSF views into a designated folder so that the runtime could safely map
them. If such a solution were to be added to JSF, then I like the idea of
treating this just like the resource library contracts "contracts" folder.
Overall, +1 with your ideas.
Thanks
Josh Juneau
juneau001_at_gmail.com
http://jj-blogger.blogspot.com
https://www.apress.com/index.php/author/author/view/id/1866
On Tue, Oct 21, 2014 at 5:03 PM, arjan tijms <arjan.tijms_at_gmail.com> wrote:
> 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
>