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;
  }
示例#2
0
 @SuppressWarnings({"UnusedDeclaration"})
 protected UIComponent findReparentedComponent(
     FaceletContext ctx, UIComponent parent, String tagId) {
   UIComponent facet = parent.getFacets().get(UIComponent.COMPOSITE_FACET_NAME);
   if (facet != null) {
     UIComponent newParent = facet.findComponent((String) parent.getAttributes().get(tagId));
     if (newParent != null) return ComponentSupport.findChildByTagId(newParent, tagId);
   }
   return null;
 }