use of com.liferay.faces.util.config.FacesConfig in project liferay-faces-bridge-impl by liferay.
the class BridgePhaseResourceImpl method getConfiguredFacesServletMappings.
protected List<ConfiguredServletMapping> getConfiguredFacesServletMappings() {
String appConfigAttrName = ApplicationConfig.class.getName();
ExternalContext externalContext = facesContext.getExternalContext();
Map<String, Object> applicationMap = externalContext.getApplicationMap();
ApplicationConfig applicationConfig = (ApplicationConfig) applicationMap.get(appConfigAttrName);
FacesConfig facesConfig = applicationConfig.getFacesConfig();
return facesConfig.getConfiguredFacesServletMappings();
}
use of com.liferay.faces.util.config.FacesConfig in project liferay-faces-alloy by liferay.
the class ResLibResourceHandler method getResourceName.
protected String getResourceName(ExternalContext externalContext) {
// Attempt to get the resource name from the "javax.faces.resource" request parameter. If it exists, then
// this is probably a non-Liferay portlet environment like Pluto.
String resourceName = externalContext.getRequestParameterMap().get("javax.faces.resource");
if (resourceName == null) {
// If the specified request was extension-mapped (suffix-mapped), then determine the resource name based
// on the configured mappings to the Faces Servlet.
Object request = externalContext.getRequest();
if (request instanceof HttpServletRequest) {
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
String servletPath = httpServletRequest.getServletPath();
if ((servletPath != null) && servletPath.startsWith(RESOURCE_IDENTIFIER)) {
Map<String, Object> applicationMap = externalContext.getApplicationMap();
String appConfigAttrName = ApplicationConfig.class.getName();
ApplicationConfig applicationConfig = (ApplicationConfig) applicationMap.get(appConfigAttrName);
FacesConfig facesConfig = applicationConfig.getFacesConfig();
List<ConfiguredServletMapping> configuredFacesServletMappings = facesConfig.getConfiguredFacesServletMappings();
resourceName = servletPath.substring(RESOURCE_IDENTIFIER.length() + 1);
for (ConfiguredServletMapping configuredFacesServletMapping : configuredFacesServletMappings) {
String configuredExtension = configuredFacesServletMapping.getExtension();
if (servletPath.endsWith(configuredExtension)) {
resourceName = resourceName.substring(0, resourceName.length() - configuredExtension.length());
break;
}
}
} else // Otherwise, it must be path-mapped.
{
resourceName = httpServletRequest.getPathInfo();
}
}
}
return resourceName;
}
Aggregations