public static String getResourceRequestPath(FacesContext context, String resourceName) { Resource resource = context.getApplication().getResourceHandler().createResource(resourceName, "primefaces"); return resource.getRequestPath(); }
public static void addComponentResource(FacesContext context, String name, String library, String target) { Application application = context.getApplication(); UIComponent componentResource = application.createComponent(UIOutput.COMPONENT_TYPE); componentResource.setRendererType(application.getResourceHandler().getRendererTypeForResourceName(name)); componentResource.getAttributes().put("name", name); componentResource.getAttributes().put("library", library); componentResource.getAttributes().put("target", target); context.getViewRoot().addComponentResource(context, componentResource, target); }
Application application = facesContext.getApplication(); ResourceHandler resourceHandler = application.getResourceHandler(); resource = resourceHandler.createResource(resourceName, resourceLibrary); resource = resourceHandler.createResource(resourceName);
return getFacesContext().getApplication().getResourceHandler();
public static Resource newResource(ResourceInfo resourceInfo, FacesContext context) { Resource resource = context.getApplication().getResourceHandler().createResource(resourceInfo.getName(), resourceInfo.getLibrary()); if (resource == null) { throw new FacesException("Resource '" + resourceInfo.getName() + "' in library '" + resourceInfo.getLibrary() + "' not found!"); } return resource; }
return getFacesContext().getApplication().getResourceHandler();
Resource resource = context.getApplication().getResourceHandler().createResource("dynamiccontent.properties", "primefaces", "image/png"); String resourcePath = resource.getRequestPath();
public static void includeCompositeComponent(UIComponent parent, String libraryName, String resourceName, String id) { // Prepare. FacesContext context = FacesContext.getCurrentInstance(); Application application = context.getApplication(); FaceletContext faceletContext = (FaceletContext) context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY); // This basically creates <ui:component> based on <composite:interface>. Resource resource = application.getResourceHandler().createResource(resourceName, libraryName); UIComponent composite = application.createComponent(context, resource); composite.setId(id); // Mandatory for the case composite is part of UIForm! Otherwise JSF can't find inputs. // This basically creates <composite:implementation>. UIComponent implementation = application.createComponent(UIPanel.COMPONENT_TYPE); implementation.setRendererType("javax.faces.Group"); composite.getFacets().put(UIComponent.COMPOSITE_FACET_NAME, implementation); // Now include the composite component file in the given parent. parent.getChildren().add(composite); parent.pushComponentToEL(context, composite); // This makes #{cc} available. try { faceletContext.includeFacelet(implementation, resource.getURL()); } catch (IOException e) { throw new FacesException(e); } finally { parent.popComponentFromEL(context); } }
protected void encodeValidationResources(FacesContext context, boolean beanValidationEnabled) throws IOException { ResponseWriter writer = context.getResponseWriter(); Resource resource = context.getApplication().getResourceHandler().createResource("validation/validation.js", "primefaces"); if (resource != null) { writer.startElement("script", null); writer.writeAttribute("type", "text/javascript", null); writer.writeAttribute("src", resource.getRequestPath(), null); writer.endElement("script"); } if (beanValidationEnabled) { resource = context.getApplication().getResourceHandler().createResource("validation/beanvalidation.js", "primefaces"); if (resource != null) { writer.startElement("script", null); writer.writeAttribute("type", "text/javascript", null); writer.writeAttribute("src", resource.getRequestPath(), null); writer.endElement("script"); } } } }
@Override public Object lookup(ArquillianResource resource, Annotation... qualifiers) { return FacesContext.getCurrentInstance().getApplication().getResourceHandler(); } }
Resource resource = context.getApplication().getResourceHandler().createResource( "dynamiccontent.properties", "primefaces", streamedContent.getContentType()); String resourcePath = resource.getRequestPath();
@Produces @Named("resource") @ApplicationScoped public ResourceHandler getResourceHandler() { return FacesContext.getCurrentInstance().getApplication().getResourceHandler(); }
protected String getImageSrc(FacesContext context, GraphicImage image) throws Exception { String name = image.getName(); if (name != null) { String libName = image.getLibrary(); ResourceHandler handler = context.getApplication().getResourceHandler(); Resource res = handler.createResource(name, libName); if (res == null) { return "RES_NOT_FOUND"; } else { String requestPath = res.getRequestPath(); return context.getExternalContext().encodeResourceURL(requestPath); } } else { return DynamicContentSrcBuilder.build(context, image.getValue(), image, image.isCache(), DynamicContentType.STREAMED_CONTENT, image.isStream()); } } }
@Bean("resource") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.TARGET_CLASS) @ConditionalOnMissingBean public ResourceHandler resourceHandler() { return FacesContext.getCurrentInstance().getApplication().getResourceHandler(); }
protected void encodeCSS(FacesContext context, String library, String resource) throws IOException { ResponseWriter writer = context.getResponseWriter(); Resource cssResource = context.getApplication().getResourceHandler().createResource(resource, library); if (cssResource == null) { throw new FacesException("Error loading css, cannot find \"" + resource + "\" resource of \"" + library + "\" library"); } else { writer.startElement("link", null); writer.writeAttribute("type", "text/css", null); writer.writeAttribute("rel", "stylesheet", null); writer.writeAttribute("href", cssResource.getRequestPath(), null); writer.endElement("link"); } }
public static void markStylesheetAsRendered(FacesContext facesContext, String libraryName, String resourceName) { facesContext.getApplication().getResourceHandler().markResourceRendered( facesContext, resourceName, libraryName); }
private void encodeScript(FacesContext context, Editor editor) throws IOException { String clientId = editor.getClientId(context); WidgetBuilder wb = getWidgetBuilder(context); wb.init("Editor", editor.resolveWidgetVar(), clientId) .attr("disabled", editor.isDisabled(), false) .attr("invalid", editor.isValid(), true) .attr("controls", editor.getControls(), null) .attr("width", editor.getWidth(), Integer.MIN_VALUE) .attr("height", editor.getHeight(), Integer.MIN_VALUE) .attr("maxlength", editor.getMaxlength(), Integer.MAX_VALUE) .callback("change", "function(e)", editor.getOnchange()); if (AgentUtils.isIE(context)) { Resource resource = context.getApplication().getResourceHandler().createResource("editor/editor-ie.css", "primefaces"); wb.attr("docCSSFile", resource.getRequestPath()); } if (editor.getMaxlength() != Integer.MAX_VALUE) { LOGGER.info("Maxlength option is deprecated and will be removed in a future version."); } wb.finish(); }
public static boolean isRenderedScript(FacesContext facesContext, String libraryName, String resourceName) { return facesContext.getApplication().getResourceHandler().isResourceRendered( facesContext, resourceName, libraryName); }
/** * * @since 2.2 * @param context * @param resourceName * @return */ public ViewResource createViewResource(FacesContext context, String resourceName) { return context.getApplication().getResourceHandler().createResource(resourceName); }
public static void markScriptAsRendered(FacesContext facesContext, String libraryName, String resourceName) { facesContext.getApplication().getResourceHandler().markResourceRendered( facesContext, resourceName, libraryName); }