{
String mapping = getResourceHandlerSupport().getMapping() != null ?
getResourceHandlerSupport().getMapping() :
"" ;
Library library = getExtendedDefaultResourceHandlerSupport().getMyFacesResourcesConfig().
getLibrary(getLibraryName());
if (library.getRequestPath() == null)
{
String localePrefix = getResourceMeta().getLocalePrefix() != null ?
getResourceMeta().getLocalePrefix() : _expectedLocalePrefix;
if (localePrefix == null)
{
// calculate current localePrefix (could be different from the one requested, e.g. on locale change)
localePrefix = getRequestLocalePrefix();
}
String path = null;
if (!getResourceHandlerSupport().isExtensionMapping())
{
path = mapping + getResourceHandlerSupport().getResourceIdentifier() + "/$/" +
localePrefix + '/' +
getLibraryName() + '/' +
getResourceName();
}
else
{
path = getResourceHandlerSupport().getResourceIdentifier() + "/$/" +
localePrefix + '/' +
getLibraryName() + '/' +
getResourceName() + mapping;
}
FacesContext facesContext = FacesContext.getCurrentInstance();
return facesContext.getApplication().getViewHandler().getResourceURL(facesContext, path);
}
else
{
//Redirect url assume prefix mapping.
FacesContext facesContext = FacesContext.getCurrentInstance();
return facesContext.getApplication().getViewHandler().getResourceURL(facesContext,
calculateRequestPath(facesContext, library.getRequestPath()));
}
}