Hi Leonardo,
Am 08.11.2012 um 20:54 schrieb Leonardo Uribe <lu4242_at_gmail.com>:
> The viewRoot is already exposed in FacesContext, so the resource
> handler check if
> exists or not and if that so, it takes the resource prefixes. The same
> happens when
> it try to get the locale of a resource. In MyFaces see:
>
> http://svn.apache.org/repos/asf/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ResourceHandlerImpl.java
>
> method getLocalePrefixForLocateResource():
>
> in few words, if the request is a resource request it tries do
> retrieve the locale
> from a query parameter "loc", otherwise check if exists a viewRoot and if
> that so it calls facesContext.getViewRoot().getLocale(), otherwise it use
> the ViewHandler to calculate it.
That's my point. You are able to calculate the locale even without a viewRoot set. So the locale feels like a request property.
If I want to change the behavior I have to overwrite either ViewHandler.calculateLocale or Application.getDefaultLocale and Application.getSupportedLocales. Not so easy.
> As you can see, we can follow the same strategy as with locale. Put the method
> in FacesContext doesn't make any difference.
Having it in the FacesContext makes a difference, because you can use it to calculate the ViewRoot. Suppose you have the facelet home.xhtml and FacesContext.getResourcePrefixes() returns ["foo"] and you have foo/home.xhtml, then foo/home.xhtml will be used instead of home.xhtml.
> Maybe we need some concrete examples
> to see how it works.
Definitely. We should collect them all and use them for a prototype in Mojarra.
Ciao Frank