use of javax.faces.application.Resource in project liferay-faces-bridge-impl by liferay.
the class ResourceHandlerBridgeImpl method handleResourceRequest.
/**
* This method handles the current request which is assumed to be a request for a {@link Resource}.
*/
@Override
public void handleResourceRequest(FacesContext facesContext) throws IOException {
ExternalContext externalContext = facesContext.getExternalContext();
Map<String, String> requestParameterMap = externalContext.getRequestParameterMap();
String resourceName = requestParameterMap.get("javax.faces.resource");
// resource to the response.
if (resourceName != null) {
String libraryName = requestParameterMap.get("ln");
if (logger.isTraceEnabled()) {
// Surround with isTraceEnabled check in order to avoid unnecessary creation of object array.
logger.trace("Handling - resourceName=[{0}], libraryName[{1}]", resourceName, libraryName);
}
// FACES-57: Provide the opportunity for applications to decorate the createResource methods of this
// class by delegating creation of the resource to the chain-of-responsibility found in the application's
// ResourceHandler.
ResourceHandler resourceHandlerChain = facesContext.getApplication().getResourceHandler();
Resource resource;
if (libraryName == null) {
resource = resourceHandlerChain.createResource(resourceName);
} else {
resource = resourceHandlerChain.createResource(resourceName, libraryName);
}
handleResource(facesContext, externalContext, resource);
} else {
logger.debug("NOT HANDLED - Missing request parameter {0} so delegating handleResourceRequest to chain", "javax.faces.resource");
getWrapped().handleResourceRequest(facesContext);
}
}
use of javax.faces.application.Resource in project liferay-faces-bridge-impl by liferay.
the class ResourceHandlerRichfacesImpl method createResource.
@Override
public Resource createResource(String resourceName) {
Resource resource = super.createResource(resourceName);
resource = createResource(resourceName, resource);
return resource;
}
use of javax.faces.application.Resource in project liferay-faces-bridge-impl by liferay.
the class ResourceHandlerOuterImpl method createResource.
@Override
public Resource createResource(String resourceName, String libraryName, String contentType) {
Resource resource = super.createResource(resourceName, libraryName, contentType);
resource = createResource(resource);
return resource;
}
use of javax.faces.application.Resource in project liferay-faces-bridge-ext by liferay.
the class JSResourceWithDisabledAMDLoaderImpl method getResourceId.
private String getResourceId() {
Resource wrappedResource = getWrapped();
String libraryName = wrappedResource.getLibraryName();
String resourceName = wrappedResource.getResourceName();
return ResourceUtil.getResourceId(libraryName, resourceName);
}
use of javax.faces.application.Resource in project primefaces by primefaces.
the class GraphicImageRenderer method getImageSrc.
protected String getImageSrc(FacesContext context, GraphicImage image) {
String name = image.getName();
if (name != null) {
String library = image.getLibrary();
ResourceHandler handler = context.getApplication().getResourceHandler();
Resource resource = handler.createResource(name, library);
if (resource == null) {
return "RES_NOT_FOUND";
}
if (image.isStream()) {
String requestPath = resource.getRequestPath();
return context.getExternalContext().encodeResourceURL(requestPath);
} else {
return ResourceUtils.toBase64(context, resource);
}
} else {
return DynamicContentSrcBuilder.build(context, image, image.getValueExpression(GraphicImage.PropertyKeys.value.name()), new Lazy<>(() -> image.getValue()), image.isCache(), image.isStream());
}
}
Aggregations