Exemplo n.º 1
2
  protected void assignUniqueId(FaceletContext ctx, UIComponent parent, String id, UIComponent c) {

    // If the id is specified as a literal, and the component is being
    // repeated (by c:forEach, for example), use generated unique ids
    // after the first instance
    if (this.id != null && !(this.id.isLiteral() && ComponentSupport.getNeedUniqueIds(ctx))) {
      c.setId(this.id.getValue(ctx));
    } else {
      UIViewRoot root = ComponentSupport.getViewRoot(ctx, parent);
      if (root != null) {
        String uid;
        IdMapper mapper = IdMapper.getMapper(ctx.getFacesContext());
        String mid = ((mapper != null) ? mapper.getAliasedId(id) : id);
        UIComponent ancestorNamingContainer = parent.getNamingContainer();
        if (null != ancestorNamingContainer && ancestorNamingContainer instanceof UniqueIdVendor) {
          uid =
              ((UniqueIdVendor) ancestorNamingContainer).createUniqueId(ctx.getFacesContext(), mid);
        } else {
          uid = root.createUniqueId(ctx.getFacesContext(), mid);
        }
        c.setId(uid);
      }
    }

    if (this.rendererType != null) {
      c.setRendererType(this.rendererType);
    }
  }
Exemplo n.º 2
0
  protected void setProperties(UIComponent component) {
    if (_binding != null) component.setValueExpression("binding", _binding);

    if (_rendered != null) component.setValueExpression("rendered", _rendered);

    String type = getRendererType();
    if (type != null) component.setRendererType(type);
  }
    private static UIComponent createThemeResource(
        FacesContext fc, String library, String resourceName) {
      UIComponent resource = fc.getApplication().createComponent("javax.faces.Output");
      resource.setRendererType("javax.faces.resource.Stylesheet");
      resource.setTransient(true);

      Map<String, Object> attrs = resource.getAttributes();
      attrs.put("name", resourceName);
      attrs.put("library", library);
      attrs.put("target", "head");

      return resource;
    }