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); }
/** * @since 2.0 */ public void addComponentResource(FacesContext context, UIComponent componentResource) { addComponentResource(context, componentResource, null); }
private void addResourceIfNecessary(UIViewRoot root, FacesContext context, UIComponent output, Class<?> clazz) { for (UIComponent c : root.getComponentResources(context, "head")) if (c.getClass() == clazz) return; // resource not found yet, so add it now root.addComponentResource(context, output, "head"); }
public void processEvent(ComponentSystemEvent event) throws AbortProcessingException { // http://javaserverfaces.java.net/nonav/docs/2.0/pdldocs/facelets/index.html // Finally make sure the component is only rendered in the header of the // HTML document. UIComponent component = event.getComponent(); FacesContext context = FacesContext.getCurrentInstance(); if (log.isLoggable(Level.FINER)) { log.finer("processEvent for component = " + component.getClass().getName()); } context.getViewRoot().addComponentResource(context, component, HTML.HEAD_ELEM); }
/** * Adds the specified {@link UIComponent} as a component resource to the * {@link javax.faces.component.UIViewRoot} * @param ctx the {@link FacesContext} for the current request * @param c the component resource */ private void pushResourceToRoot(FacesContext ctx, UIComponent c) { ctx.getViewRoot().addComponentResource(ctx, c, (String) c .getAttributes().get("target")); }
private void addComponentResource() { final FacesContext facesContext = getFacesContext(); final UIViewRoot root = facesContext.getViewRoot(); root.addComponentResource(facesContext, this); }
private void addComponentResource() { final FacesContext facesContext = getFacesContext(); final UIViewRoot root = facesContext.getViewRoot(); root.addComponentResource(facesContext, this); }
/** * Adds the specified {@link UIComponent} as a component resource to the * {@link javax.faces.component.UIViewRoot} * @param ctx the {@link FacesContext} for the current request * @param c the component resource */ private void pushResourceToRoot(FacesContext ctx, UIComponent c) { ctx.getViewRoot().addComponentResource(ctx, c, (String) c .getAttributes().get("target")); }
private void addResourceIfNecessary(UIViewRoot root, FacesContext context, UIComponent output, Class<?> clazz) { for (UIComponent c : root.getComponentResources(context, "head")) if (c.getClass() == clazz) return; // resource not found yet, so add it now root.addComponentResource(context, output, "head"); }
/** * Adds the specified {@link UIComponent} as a component resource to the * {@link javax.faces.component.UIViewRoot} * @param ctx the {@link FacesContext} for the current request * @param c the component resource */ private void pushResourceToRoot(FacesContext ctx, UIComponent c) { ctx.getViewRoot().addComponentResource(ctx, c, (String) c .getAttributes().get("target")); }
/** * Adds the specified {@link UIComponent} as a component resource to the * {@link javax.faces.component.UIViewRoot} * @param ctx the {@link FacesContext} for the current request * @param c the component resource */ private void pushResourceToRoot(FacesContext ctx, UIComponent c) { ctx.getViewRoot().addComponentResource(ctx, c, (String) c .getAttributes().get("target")); }
private static UIComponent addComponentResource(UIComponent resource, String target) { FacesContext context = FacesContext.getCurrentInstance(); if (resource.getId() == null) { Hacks.setComponentResourceUniqueId(context, resource); } context.getViewRoot().addComponentResource(context, resource, target); return resource; }
private static UIComponent addComponentResource(UIComponent resource, String target) { FacesContext context = FacesContext.getCurrentInstance(); if (resource.getId() == null) { Hacks.setComponentResourceUniqueId(context, resource); } context.getViewRoot().addComponentResource(context, resource, target); return resource; }
private void addResourceIfNecessary(UIViewRoot root, FacesContext context, UIOutput output) { Object libToAdd = output.getAttributes().get("library"); Object nameToAdd = output.getAttributes().get("name"); for (UIComponent c : root.getComponentResources(context, "head")) { String library = (String) c.getAttributes().get("library"); String name = (String) c.getAttributes().get("name"); if (library != null && library.equals(libToAdd) && name != null && name.equals(nameToAdd)) return; } root.addComponentResource(context, output, "head"); }
private void addResourceIfNecessary(UIViewRoot root, FacesContext context, UIOutput output) { Object libToAdd = output.getAttributes().get("library"); Object nameToAdd = output.getAttributes().get("name"); for (UIComponent c : root.getComponentResources(context, "head")) { String library = (String) c.getAttributes().get("library"); String name = (String) c.getAttributes().get("name"); if (library != null && library.equals(libToAdd) && name != null && name.equals(nameToAdd)) return; } root.addComponentResource(context, output, "head"); }
/** * Add a new resource. */ private void addGeneratedResource(FacesContext context, String resourceName, String rendererType, String value, UIViewRoot view) { final UIOutput resource = new UIOutput(); resource.getAttributes().put("name", resourceName); resource.setRendererType(rendererType); resource.getAttributes().put("library", value); view.addComponentResource(context, resource, HEAD); }
/** * Add a new resource. */ private void addGeneratedResource(FacesContext context, String resourceName, String rendererType, String value, UIViewRoot view) { final UIOutput resource = new UIOutput(); resource.getAttributes().put("name", resourceName); resource.setRendererType(rendererType); resource.getAttributes().put("library", value); view.addComponentResource(context, resource, HEAD); }
protected void pushCssToHead(String library, String name) { UIOutput css = new UIOutput(); css.setRendererType("javax.faces.resource.Stylesheet"); css.getAttributes().put("library", library); css.getAttributes().put("name", name); FacesContext context = this.getFacesContext(); context.getViewRoot().addComponentResource(context, css, "head"); }
/** * Add a new resource. */ private void addGeneratedResource(FacesContext context, String resourceName, String rendererType, String value, UIViewRoot view) { final UIOutput resource = new UIOutput(); resource.getAttributes().put("name", resourceName); resource.setRendererType(rendererType); resource.getAttributes().put("library", value); view.addComponentResource(context, resource, HEAD); }
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); }