UIOutput css = new UIOutput(); css.setRendererType("javax.faces.resource.Stylesheet"); css.getAttributes().put("library", "mylibrary"); css.getAttributes().put("name", "bar.css"); UIOutput js = new UIOutput(); js.setRendererType("javax.faces.resource.Script"); js.getAttributes().put("library", "mylibrary"); js.getAttributes().put("name", "bar.js"); FacesContext context = FacesContext.getCurrentInstance(); context.getViewRoot().addComponentResource(context, css, "head"); context.getViewRoot().addComponentResource(context, js, "head");
private static UIComponent createJsfJs() { UIOutput output = new UIOutput(); output.setRendererType("javax.faces.resource.Script"); output.getAttributes().put("name", JSF_SCRIPT_RESOURCE_NAME); output.getAttributes().put("library", JSF_SCRIPT_LIBRARY_NAME); return output; }
private static UIComponent createJsfJs() { UIOutput output = new UIOutput(); output.setRendererType("javax.faces.resource.Script"); output.getAttributes().put("name", JSF_SCRIPT_RESOURCE_NAME); output.getAttributes().put("library", JSF_SCRIPT_LIBRARY_NAME); return output; }
private static UIComponent createJsfJs() { UIOutput output = new UIOutput(); output.setRendererType("javax.faces.resource.Script"); output.getAttributes().put("name", JSF_SCRIPT_RESOURCE_NAME); output.getAttributes().put("library", JSF_SCRIPT_LIBRARY_NAME); return output; }
/** * 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); }
/** * 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); }
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"); }
public static UIComponent createResourceComponent(String name, String lib, String rendererType, boolean isTransient){ UIOutput res = new UIOutput(); res.setRendererType(rendererType); res.setTransient(isTransient); Map attrs = res.getAttributes(); attrs.put("name", name); if (lib != null && lib.trim().length() > 0) { attrs.put("library", lib); } attrs.put("version", "fubar"); return res; }
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"); }
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { rendererParamsNotNull(context, component); UIOutput output = (UIOutput) component; boolean componentDisabled = false; if (output.getAttributes().get("disabled") != null) { if ((output.getAttributes().get("disabled")).equals(Boolean.TRUE)) { componentDisabled = true; } } if (componentDisabled) { renderAsDisabled(context, output); } else { renderAsActive(context, output); } }
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { rendererParamsNotNull(context, component); UIOutput output = (UIOutput) component; boolean componentDisabled = false; if (output.getAttributes().get("disabled") != null) { if ((output.getAttributes().get("disabled")).equals(Boolean.TRUE)) { componentDisabled = true; } } if (componentDisabled) { renderAsDisabled(context, output); } else { renderAsActive(context, output); } }
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { rendererParamsNotNull(context, component); UIOutput output = (UIOutput) component; boolean componentDisabled = false; if (output.getAttributes().get("disabled") != null) { if ((output.getAttributes().get("disabled")).equals(Boolean.TRUE)) { componentDisabled = true; } } if (componentDisabled) { renderAsDisabled(context, output); } else { renderAsActive(context, output); } }
private static UIComponent addScriptResource(String libraryName, String resourceName, String target) { FacesContext context = FacesContext.getCurrentInstance(); String id = (libraryName != null ? (libraryName.replaceAll("\\W+", "_") + "_") : "") + resourceName.replaceAll("\\W+", "_"); for (UIComponent existingResource : context.getViewRoot().getComponentResources(context, target)) { if (id.equals(existingResource.getId())) { return existingResource; } } UIOutput outputScript = createScriptResource(); outputScript.setId(id); if (libraryName != null) { outputScript.getAttributes().put("library", libraryName); } outputScript.getAttributes().put("name", resourceName); return addComponentResource(outputScript, target); }
private static UIComponent addScriptResource(String libraryName, String resourceName, String target) { FacesContext context = FacesContext.getCurrentInstance(); String id = (libraryName != null ? (libraryName.replaceAll("\\W+", "_") + "_") : "") + resourceName.replaceAll("\\W+", "_"); for (UIComponent existingResource : context.getViewRoot().getComponentResources(context, target)) { if (id.equals(existingResource.getId())) { return existingResource; } } UIOutput outputScript = createScriptResource(); outputScript.setId(id); if (libraryName != null) { outputScript.getAttributes().put("library", libraryName); } outputScript.getAttributes().put("name", resourceName); return addComponentResource(outputScript, target); }
@Override public void processEvent(ComponentSystemEvent event) throws AbortProcessingException { if(event instanceof PostAddToViewEvent) { UIOutput css = new UIOutput(); css.setRendererType("javax.faces.resource.Stylesheet"); css.getAttributes().put("library", "ahtutilsCss"); css.getAttributes().put("name", "panelGrid.css"); FacesContext context = this.getFacesContext(); context.getViewRoot().addComponentResource(context, css, "head"); } super.processEvent(event); }
String fieldsetHTMLText ="<fieldset id=\"blah\"></fieldset>"; UIOutput verbatim = new UIOutput(); verbatim.setRendererType("javax.faces.Text"); verbatim.getAttributes().put("escape", false); verbatim.setValue(fieldsetHTMLText);
UIOutput fieldsetStart = new UIOutput(); fieldsetStart.setRendererType("javax.faces.Text"); fieldsetStart.getAttributes().put("escape", false); fieldsetStart.setValue("<fieldset>"); UIOutput fieldsetClose = new UIOutput(); fieldsetClose.setRendererType("javax.faces.Text"); fieldsetClose.getAttributes().put("escape", false); fieldsetClose.setValue("</fieldset>"); HtmlInputText inputText = (HtmlInputText) app.createComponent(HtmlInputText.COMPONENT_TYPE); form.getChildren().add(fieldsetStart); form.getChildren().add(inputText); form.getChildren().add(fieldsetClose);
UIOutput fieldset = new UIOutput(); fieldset.setRendererType("javax.faces.Text"); fieldset.getAttributes().put("escape", false); fieldset.setValue("<fieldset></fieldset>");