public static UIComponent addFacet(
      FacesContext context,
      ServletRequest req,
      UIComponent parent,
      String facetName,
      ValueExpression binding,
      Class childClass)
      throws Exception {
    if (context == null) context = FacesContext.getCurrentInstance();

    if (parent == null) {
      UIComponentClassicTagBase parentTag =
          (UIComponentClassicTagBase) req.getAttribute("caucho.jsf.parent");

      parent = parentTag.getComponentInstance();
    }

    UIComponent child = null;

    if (binding != null) child = (UIComponent) binding.getValue(context.getELContext());

    if (child == null) child = (UIComponent) childClass.newInstance();

    if (parent != null) parent.getFacets().put(facetName, child);

    if (binding != null) binding.setValue(context.getELContext(), child);

    return child;
  }
  public static UIComponent addPersistent(
      FacesContext context,
      ServletRequest req,
      UIComponent parent,
      ValueExpression binding,
      Class childClass)
      throws Exception {
    if (context == null) context = FacesContext.getCurrentInstance();

    if (parent == null) {
      UIComponentClassicTagBase parentTag =
          (UIComponentClassicTagBase) req.getAttribute("caucho.jsf.parent");

      parent = parentTag.getComponentInstance();

      BodyContent body = parentTag.getBodyContent();

      addVerbatim(parent, body);
    }

    UIComponent child = null;

    if (binding != null) child = (UIComponent) binding.getValue(context.getELContext());

    if (child == null) {
      child = (UIComponent) childClass.newInstance();

      // jsf/3251
      if (binding != null) binding.setValue(context.getELContext(), child);
    }

    if (parent != null) parent.getChildren().add(child);

    return child;
  }
Exemplo n.º 3
0
 static final int evalInt(ValueExpression expr, FacesContext context) {
   try {
     return (Integer) expr.getValue(context.getELContext());
   } catch (ELException e) {
     throw new FacesException(e);
   }
 }
Exemplo n.º 4
0
 static final String evalString(ValueExpression expr, FacesContext context) {
   try {
     return (String) expr.getValue(context.getELContext());
   } catch (ELException e) {
     throw new FacesException(e);
   }
 }
Exemplo n.º 5
0
  static final boolean evalBoolean(ValueExpression expr, FacesContext context) {
    try {
      Object value = expr.getValue(context.getELContext());

      if (value == null) return false;
      else if (value instanceof Boolean) return ((Boolean) value).booleanValue();
      else if (value instanceof String) return "true".equalsIgnoreCase((String) value);
      else return false;
    } catch (ELException e) {
      throw new FacesException(e);
    }
  }