Exemple #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);
    }
  }
Exemple #2
0
  /*
   * Internal hook that allows us to perform common processing for all
   * components after they are populated.  At the moment, the only common
   * processing we need to perform is applying wrapping AjaxBehaviors,
   * if any exist.
   */
  private void privateOnComponentPopulated(FaceletContext ctx, UIComponent c) {

    if (c instanceof ClientBehaviorHolder) {
      FacesContext context = ctx.getFacesContext();
      AjaxBehaviors ajaxBehaviors = AjaxBehaviors.getAjaxBehaviors(context, false);
      if (ajaxBehaviors != null) {
        ajaxBehaviors.addBehaviors(context, (ClientBehaviorHolder) c);
      }
    }
    if (c instanceof EditableValueHolder) {
      processValidators(ctx.getFacesContext(), (EditableValueHolder) c);
    }
  }
Exemple #3
0
 public void applyAttachedObject(FacesContext context, UIComponent parent) {
   FaceletContext ctx =
       (FaceletContext) context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
   // cast to a ValueHolder
   ValueHolder vh = (ValueHolder) parent;
   ValueExpression ve = null;
   Converter c = null;
   if (owner.getBinding() != null) {
     ve = owner.getBinding().getValueExpression(ctx, Converter.class);
     c = (Converter) ve.getValue(ctx);
   }
   if (c == null) {
     c = this.createConverter(ctx);
     if (ve != null) {
       ve.setValue(ctx, c);
     }
   }
   if (c == null) {
     throw new TagException(owner.getTag(), "No Converter was created");
   }
   owner.setAttributes(ctx, c);
   vh.setConverter(c);
   Object lv = vh.getLocalValue();
   FacesContext faces = ctx.getFacesContext();
   if (lv instanceof String) {
     vh.setValue(c.getAsObject(faces, parent, (String) lv));
   }
 }
Exemple #4
0
  private void applyCompositeComponent(FaceletContext ctx, UIComponent c) throws IOException {

    FacesContext facesContext = ctx.getFacesContext();
    FaceletFactory factory =
        (FaceletFactory) RequestStateManager.get(facesContext, RequestStateManager.FACELET_FACTORY);
    VariableMapper orig = ctx.getVariableMapper();

    UIPanel facetComponent;
    if (ComponentHandler.isNew(c)) {
      facetComponent = (UIPanel) facesContext.getApplication().createComponent("javax.faces.Panel");
      facetComponent.setRendererType("javax.faces.Group");
      c.getFacets().put(UIComponent.COMPOSITE_FACET_NAME, facetComponent);
    } else {
      facetComponent = (UIPanel) c.getFacets().get(UIComponent.COMPOSITE_FACET_NAME);
    }
    assert (null != facetComponent);

    try {
      Facelet f = factory.getFacelet(ccResource.getURL());

      VariableMapper wrapper =
          new VariableMapperWrapper(orig) {

            @Override
            public ValueExpression resolveVariable(String variable) {
              return super.resolveVariable(variable);
            }
          };
      ctx.setVariableMapper(wrapper);
      f.apply(facesContext, facetComponent);
    } finally {
      ctx.setVariableMapper(orig);
    }
  }
Exemple #5
0
  public UIComponent createComponent(FaceletContext ctx) {

    FacesContext context = ctx.getFacesContext();
    UIComponent cc;
    // we have to handle the binding here, as Application doesn't
    // expose a method to do so with Resource.
    if (binding != null) {
      ValueExpression ve = binding.getValueExpression(ctx, UIComponent.class);
      cc = (UIComponent) ve.getValue(ctx);
      if (cc != null && !UIComponent.isCompositeComponent(cc)) {
        if (LOGGER.isLoggable(Level.SEVERE)) {
          LOGGER.log(Level.SEVERE, "jsf.compcomp.binding.eval.non.compcomp", binding.toString());
        }
        cc = null;
      }
      if (cc == null) {
        cc = context.getApplication().createComponent(context, ccResource);
        ve.setValue(ctx, cc);
      }
    } else {
      cc = context.getApplication().createComponent(context, ccResource);
    }
    setCompositeComponent(context, cc);

    return cc;
  }
Exemple #6
0
 /**
  * Create a Converter instance
  *
  * @param ctx FaceletContext to use
  * @return Converter instance, cannot be null
  */
 private Converter createConverter(FaceletContext ctx) {
   if (owner.getConverterId(ctx) == null) {
     throw new TagException(
         owner.getTag(),
         "Default behavior invoked of requiring a converter-id passed in the constructor, must override ConvertHandler(ConverterConfig)");
   }
   return ctx.getFacesContext().getApplication().createConverter(owner.getConverterId(ctx));
 }
Exemple #7
0
  private void throwRequiredException(FaceletContext ctx, UIComponent compositeParent) {

    throw new TagException(
        this.tag,
        "Unable to find any children components "
            + "nested within parent composite component with id '"
            + compositeParent.getClientId(ctx.getFacesContext())
            + '\'');
  }
Exemple #8
0
  protected boolean pushComponentToEL(
      FaceletContext ctx, UIComponent c, CompositeComponentStackManager ccStackManager) {

    c.pushComponentToEL(ctx.getFacesContext(), c);
    boolean compcompPushed = false;

    if (UIComponent.isCompositeComponent(c)) {
      compcompPushed = ccStackManager.push(c, TreeCreation);
    }
    return compcompPushed;
  }
Exemple #9
0
  protected void popComponentFromEL(
      FaceletContext ctx,
      UIComponent c,
      CompositeComponentStackManager ccStackManager,
      boolean compCompPushed) {

    c.popComponentFromEL(ctx.getFacesContext());
    if (compCompPushed) {
      ccStackManager.pop(TreeCreation);
    }
  }
    public void applyMetadata(FaceletContext ctx, Object instance) {
      AbstractDataScroller datascroller = (AbstractDataScroller) instance;

      ValueExpression ve = page.getValueExpression(ctx, int.class);
      if (ve.isLiteralText()) {
        Integer value = (Integer) ve.getValue(ctx.getFacesContext().getELContext());
        datascroller.setPage(value);
      } else {
        datascroller.setValueExpression("page", ve);
      }
    }
Exemple #11
0
  /**
   * Specialized implementation to prevent caching of the MetaRuleset when ProjectStage is
   * Development.
   */
  @Override
  public void setAttributes(FaceletContext ctx, Object instance) {

    if (instance != null) {
      if (ctx.getFacesContext().isProjectStage(ProjectStage.Development)) {
        Metadata meta = createMetaRuleset(instance.getClass()).finish();
        meta.applyMetadata(ctx, instance);
      } else {
        super.setAttributes(ctx, instance);
      }
    }
  }
  @Override
  protected AjaxBehavior createBehavior(FaceletContext ctx, String eventName) {
    Application application = ctx.getFacesContext().getApplication();
    AjaxBehavior behavior = (AjaxBehavior) application.createBehavior(AjaxBehavior.BEHAVIOR_ID);

    setBehaviorAttribute(
        ctx, behavior, this.process, AjaxBehavior.PropertyKeys.process.expectedType);
    setBehaviorAttribute(ctx, behavior, this.update, AjaxBehavior.PropertyKeys.update.expectedType);
    setBehaviorAttribute(
        ctx, behavior, this.onstart, AjaxBehavior.PropertyKeys.onstart.expectedType);
    setBehaviorAttribute(
        ctx, behavior, this.onerror, AjaxBehavior.PropertyKeys.onerror.expectedType);
    setBehaviorAttribute(
        ctx, behavior, this.onsuccess, AjaxBehavior.PropertyKeys.onsuccess.expectedType);
    setBehaviorAttribute(
        ctx, behavior, this.oncomplete, AjaxBehavior.PropertyKeys.oncomplete.expectedType);
    setBehaviorAttribute(
        ctx, behavior, this.disabled, AjaxBehavior.PropertyKeys.disabled.expectedType);
    setBehaviorAttribute(
        ctx, behavior, this.immediate, AjaxBehavior.PropertyKeys.immediate.expectedType);
    setBehaviorAttribute(ctx, behavior, this.global, AjaxBehavior.PropertyKeys.global.expectedType);
    setBehaviorAttribute(ctx, behavior, this.async, AjaxBehavior.PropertyKeys.async.expectedType);
    setBehaviorAttribute(
        ctx, behavior, this.partialSubmit, AjaxBehavior.PropertyKeys.partialSubmit.expectedType);
    setBehaviorAttribute(
        ctx, behavior, this.listener, AjaxBehavior.PropertyKeys.listener.expectedType);
    setBehaviorAttribute(
        ctx, behavior, this.resetValues, AjaxBehavior.PropertyKeys.resetValues.expectedType);
    setBehaviorAttribute(
        ctx,
        behavior,
        this.ignoreAutoUpdate,
        AjaxBehavior.PropertyKeys.ignoreAutoUpdate.expectedType);
    setBehaviorAttribute(ctx, behavior, this.delay, AjaxBehavior.PropertyKeys.delay.expectedType);
    setBehaviorAttribute(
        ctx, behavior, this.timeout, AjaxBehavior.PropertyKeys.timeout.expectedType);
    setBehaviorAttribute(
        ctx,
        behavior,
        this.partialSubmitFilter,
        AjaxBehavior.PropertyKeys.partialSubmitFilter.expectedType);

    if (listener != null) {
      behavior.addAjaxBehaviorListener(
          new AjaxBehaviorListenerImpl(
              this.listener.getMethodExpression(ctx, Object.class, new Class[] {}),
              this.listener.getMethodExpression(
                  ctx, Object.class, new Class[] {AjaxBehaviorEvent.class})));
    }

    return behavior;
  }
  @Override
  protected ConfirmBehavior createBehavior(
      FaceletContext ctx, String eventName, UIComponent parent) {
    Application application = ctx.getFacesContext().getApplication();
    ConfirmBehavior behavior =
        (ConfirmBehavior) application.createBehavior(ConfirmBehavior.BEHAVIOR_ID);

    setBehaviorAttribute(
        ctx, behavior, this.header, ConfirmBehavior.PropertyKeys.header.expectedType);
    setBehaviorAttribute(
        ctx, behavior, this.message, ConfirmBehavior.PropertyKeys.message.expectedType);
    setBehaviorAttribute(ctx, behavior, this.icon, ConfirmBehavior.PropertyKeys.icon.expectedType);

    return behavior;
  }
Exemple #14
0
  public void apply(FaceletContext ctx, UIComponent parent) throws IOException {

    UIComponent compositeParent = UIComponent.getCurrentCompositeComponent(ctx.getFacesContext());
    if (compositeParent == null) {
      return;
    }

    boolean required = ((this.required != null) && this.required.getBoolean(ctx));

    if (compositeParent.getChildCount() == 0 && required) {
      throwRequiredException(ctx, compositeParent);
    }

    List<UIComponent> compositeChildren = compositeParent.getChildren();
    List<UIComponent> parentChildren = parent.getChildren();
    parentChildren.addAll(compositeChildren);
  }
Exemple #15
0
  protected void addComponentToView(
      FaceletContext ctx, UIComponent parent, UIComponent c, boolean componentFound) {

    FacesContext context = ctx.getFacesContext();
    boolean suppressEvents = ComponentSupport.suppressViewModificationEvents(context);
    boolean compcomp = UIComponent.isCompositeComponent(c);

    if (suppressEvents && componentFound && !compcomp) {
      context.setProcessingEvents(false);
    }

    ComponentSupport.addComponent(ctx, parent, c);

    if (suppressEvents && componentFound && !compcomp) {
      context.setProcessingEvents(true);
    }
  }
  public void apply(FaceletContext ctx, UIComponent parent) throws IOException {

    // only process if it's been created
    if (parent == null || !ComponentHandler.isNew(parent)) {
      return;
    }

    if (isEventSource(parent)) {
      applyAttachedObject(ctx.getFacesContext(), parent);
    } else if (UIComponent.isCompositeComponent(parent)) {
      // Allow the composite component to know about the target component.
      TagHandlerUtils.getOrCreateRetargetableHandlersList(parent).add(this);
    } else {
      throw new TagException(
          this.tag, "Parent does not match event source requirements: " + parent);
    }
  }
Exemple #17
0
  protected void doNewComponentActions(FaceletContext ctx, String id, UIComponent c) {

    if (log.isLoggable(Level.FINE)) {
      log.fine(owner.getTag() + " Component[" + id + "] Created: " + c.getClass().getName());
    }
    // If this is NOT a composite component...
    if (null == createCompositeComponentDelegate) {
      // set the attributes and properties into the UIComponent instance.
      owner.setAttributes(ctx, c);
    }
    // otherwise, allow the composite component code to do it.

    // mark it owned by a facelet instance
    c.getAttributes().put(ComponentSupport.MARK_CREATED, id);

    if (ctx.getFacesContext().isProjectStage(ProjectStage.Development)) {
      // inject the location into the component
      c.getAttributes().put(UIComponent.VIEW_LOCATION_KEY, owner.getTag().getLocation());
    }
  }
 /**
  * Adds a default disabled "select a value" option if widget is not required.
  *
  * @since 6.0
  */
 protected FaceletHandler getFirstHandler(
     FaceletContext ctx, FaceletHandlerHelper helper, Widget widget, FaceletHandler nextHandler) {
   Object doNotDisplay = widget.getProperty(SelectPropertyMappings.notDisplayDefaultOption.name());
   if (doNotDisplay != null) {
     if (Boolean.TRUE.equals(doNotDisplay)) {
       return null;
     }
     if (doNotDisplay instanceof String) {
       Object res = ComponentTagUtils.resolveElExpression(ctx, (String) doNotDisplay);
       if ((res instanceof Boolean && Boolean.TRUE.equals(res))
           || (res instanceof String && Boolean.parseBoolean((String) res))) {
         return null;
       }
     }
   }
   String bundleName = ctx.getFacesContext().getApplication().getMessageBundle();
   String localizedExpression = "#{" + bundleName + "['label.vocabulary.selectValue']}";
   WidgetSelectOption selectOption =
       new WidgetSelectOptionImpl("", "", localizedExpression, "", Boolean.FALSE, Boolean.TRUE);
   return getBareOptionFaceletHandler(ctx, helper, widget, selectOption, nextHandler);
 }
Exemple #19
0
  /**
   * If the binding attribute was specified, use that in conjuction with our componentType String
   * variable to call createComponent on the Application, otherwise just pass the componentType
   * String.
   *
   * <p>If the binding was used, then set the ValueExpression "binding" on the created UIComponent.
   *
   * @see Application#createComponent(javax.faces.el.ValueBinding, javax.faces.context.FacesContext,
   *     java.lang.String)
   * @see Application#createComponent(java.lang.String)
   * @param ctx FaceletContext to use in creating a component
   * @return
   */
  private UIComponent createComponent(FaceletContext ctx) {

    if (null != createCompositeComponentDelegate) {
      return createCompositeComponentDelegate.createComponent(ctx);
    }

    UIComponent c;
    FacesContext faces = ctx.getFacesContext();
    Application app = faces.getApplication();
    if (this.binding != null) {
      ValueExpression ve = this.binding.getValueExpression(ctx, Object.class);
      c = app.createComponent(ve, faces, this.componentType, this.rendererType);
      if (c != null) {
        // Make sure the component supports 1.2
        c.setValueExpression("binding", ve);
      }
    } else {
      c = app.createComponent(faces, this.componentType, this.rendererType);
    }
    return c;
  }
Exemple #20
0
  protected void doOrphanedChildCleanup(FaceletContext ctx, UIComponent parent, UIComponent c) {

    ComponentSupport.finalizeForDeletion(c);
    if (getFacetName(parent) == null) {
      FacesContext context = ctx.getFacesContext();
      boolean suppressEvents = ComponentSupport.suppressViewModificationEvents(context);

      if (suppressEvents) {
        // if the component has already been found, it will be removed
        // and added back to the view.  We don't want to publish events
        // for this case.
        context.setProcessingEvents(false);
      }
      // suppress the remove event for this case since it will be re-added
      parent.getChildren().remove(c);
      if (suppressEvents) {
        // re-enable event processing
        context.setProcessingEvents(true);
      }
    }
  }
Exemple #21
0
  @Override
  public void applyNextHandler(FaceletContext ctx, UIComponent c)
      throws IOException, FacesException, ELException {

    // attributes need to be applied before any action is taken on
    // nested children handlers or the composite component handlers
    // as there may be an expression evaluated at tree creation time
    // that needs access to these attributes
    setAttributes(ctx, c);

    // Allow any nested elements that reside inside the markup element
    // for this tag to get applied
    super.applyNextHandler(ctx, c);

    // Apply the facelet for this composite component
    applyCompositeComponent(ctx, c);

    // Allow any PDL declared attached objects to be retargeted
    if (ComponentHandler.isNew(c)) {
      FacesContext context = ctx.getFacesContext();
      String viewId = context.getViewRoot().getViewId();
      // PENDING(rlubke): performance
      ViewDeclarationLanguageFactory factory =
          (ViewDeclarationLanguageFactory)
              FactoryFinder.getFactory(FactoryFinder.VIEW_DECLARATION_LANGUAGE_FACTORY);

      ViewDeclarationLanguage vdl = factory.getViewDeclarationLanguage(viewId);
      vdl.retargetAttachedObjects(context, c, getAttachedObjectHandlers(c, false));
      vdl.retargetMethodExpressions(context, c);

      // RELEASE_PENDING This is *ugly*.  See my comments in
      // ComponentTagHandlerDelegateImpl at the end of the apply()
      // method
      if (StateContext.getStateContext(context).partialStateSaving(context, viewId)) {
        markInitialState(c);
      }
    }
  }
Exemple #22
0
 @Override
 public void apply(FaceletContext ctx, UIComponent parent)
     throws IOException, FacesException, FaceletException, ELException {
   // only process if it's been created
   if (parent == null || !(parent.getParent() == null)) {
     return;
   }
   if (parent instanceof ValueHolder) {
     owner.applyAttachedObject(ctx.getFacesContext(), parent);
   } else if (parent.getAttributes().containsKey(Resource.COMPONENT_RESOURCE_KEY)) {
     if (null == owner.getFor()) {
       // PENDING(): I18N
       throw new TagException(
           owner.getTag(),
           "converter tags nested within composite components must have a non-null \"for\" attribute");
     }
     // Allow the composite component to know about the target
     // component.
     CompositeComponentTagHandler.getAttachedObjectHandlers(parent).add(owner);
   } else {
     throw new TagException(owner.getTag(), "Parent not an instance of ValueHolder: " + parent);
   }
 }
 public void onComponentCreated(FaceletContext ctx, UIComponent c, UIComponent parent) {
   try {
     final FacesContext facesContext = ctx.getFacesContext();
     final Object pathValue = pathAttribute.getValueExpression(ctx, String.class).getValue(ctx);
     final String path;
     if (pathValue == null) {
       throw new FacesException("Value for properties file path is null");
     }
     if (!pathValue.toString().startsWith("/")) {
       path = "/WEB-INF/" + pathValue;
     } else {
       path = pathValue.toString();
     }
     @SuppressWarnings("unused")
     final String charsetName;
     if (charsetAttribute == null) {
       charsetName = "UTF-8";
     } else {
       final Object encodingValue =
           charsetAttribute.getValueExpression(ctx, String.class).getValue(ctx);
       if (encodingValue == null) {
         charsetName = "UTF-8";
       } else {
         charsetName = encodingValue.toString();
       }
     }
     final ExternalContext externalContext = facesContext.getExternalContext();
     final Properties properties;
     final InputStream stream = externalContext.getResourceAsStream(path);
     try {
       properties = new Properties();
       try {
         properties.load(stream);
       } catch (IOException e) {
         final FacesException ex =
             new FacesException("Unable to load properties: " + e.getMessage());
         ex.setStackTrace(e.getStackTrace());
         throw ex;
       }
     } finally {
       try {
         stream.close();
       } catch (IOException e) {
         log.warning("Failed to close resource stream: " + e.getMessage());
       }
     }
     final NodeMap nodeMap = new NodeHashMap();
     for (Map.Entry<Object, Object> entry : properties.entrySet()) {
       NodeMap loc = nodeMap;
       for (String part : new DelimitedStringList(entry.getKey().toString(), '.')) {
         if (loc.containsKey(part)) {
           loc = loc.get(part);
         } else {
           final NodeMap newMap = new NodeHashMap();
           loc.put(part, newMap);
           loc = newMap;
         }
       }
       loc.setNodeValue(entry.getValue().toString());
     }
     nodeMap.lock();
     final UIProperties uiProperties = ((UIProperties) c);
     uiProperties.setPropertiesMap(nodeMap);
     final Object varValue = varAttribute.getValueExpression(ctx, String.class).getValue(ctx);
     if (varValue == null) {
       throw new TagException(tag, "Value of 'var' attribute cannot be null");
     }
     uiProperties.setVar(varValue.toString());
     uiProperties.updatePropertyMap(facesContext);
   } catch (TagException tex) {
     throw tex;
   } catch (RuntimeException rex) {
     TagException tex =
         new TagException(
             tag,
             "An exception of type "
                 + rex.getClass().getName()
                 + " occurred: "
                 + rex.getMessage());
     tex.setStackTrace(rex.getStackTrace());
     throw tex;
   }
 }
 /**
  * Returns a new DateTimeConverter
  *
  * @see DateTimeConverter
  */
 protected Converter createConverter(FaceletContext ctx)
     throws FacesException, ELException, FaceletException {
   return ctx.getFacesContext().getApplication().createConverter(DateTimeConverter.CONVERTER_ID);
 }
Exemple #25
0
 public void applyMetadata(FaceletContext ctx, Object instance) {
   ((ValueHolder) instance)
       .setConverter(ctx.getFacesContext().getApplication().createConverter(this.converterId));
 }
Exemple #26
0
  /**
   * Method handles UIComponent tree creation in accordance with the JSF 1.2 spec.
   *
   * <ol>
   *   <li>First determines this UIComponent's id by calling {@link
   *       javax.faces.view.facelets.ComponentHandler#getTagId()}.
   *   <li>Search the parent for an existing UIComponent of the id we just grabbed
   *   <li>If found, {@link
   *       com.sun.faces.facelets.tag.jsf.ComponentSupport#markForDeletion(javax.faces.component.UIComponent)
   *       mark} its children for deletion.
   *   <li>If <i>not</i> found, call {@link #createComponent(FaceletContext) createComponent}.
   *       <ol>
   *         <li>Only here do we apply {@link
   *             com.sun.faces.facelets.tag.MetaTagHandlerImpl#setAttributes(FaceletContext,
   *             Object)}
   *         <li>Set the UIComponent's id
   *         <li>Set the RendererType of this instance
   *       </ol>
   *   <li>Now apply the nextHandler, passing the UIComponent we've created/found.
   *   <li>Now add the UIComponent to the passed parent
   *   <li>Lastly, if the UIComponent already existed (found), then {@link
   *       ComponentSupport#finalizeForDeletion(UIComponent) finalize} for deletion.
   * </ol>
   *
   * @throws TagException if the UIComponent parent is null
   */
  @Override
  public void apply(FaceletContext ctx, UIComponent parent) throws IOException {
    FacesContext context = ctx.getFacesContext();

    // make sure our parent is not null
    if (parent == null) {
      throw new TagException(owner.getTag(), "Parent UIComponent was null");
    }

    // our id
    String id = ctx.generateUniqueId(owner.getTagId());

    // grab our component
    UIComponent c = findChild(ctx, parent, id);
    if (null == c
        && context.isPostback()
        && UIComponent.isCompositeComponent(parent)
        && parent.getAttributes().get(id) != null) {
      c = findReparentedComponent(ctx, parent, id);
    } else {
      /**
       * If we found a child that is dynamic, the actual parent might have changed, so we need to
       * remove it from the actual parent. The reapplyDynamicActions will then replay the actions
       * and will make sure it ends up in the correct order.
       */
      if (c != null
          && c.getParent() != parent
          && c.getAttributes().containsKey(DYNAMIC_COMPONENT)) {
        c.getParent().getChildren().remove(c);
      }
    }

    boolean componentFound = false;
    if (c != null) {
      componentFound = true;
      doExistingComponentActions(ctx, id, c);
    } else {
      c = this.createComponent(ctx);

      doNewComponentActions(ctx, id, c);
      assignUniqueId(ctx, parent, id, c);

      // hook method
      owner.onComponentCreated(ctx, c, parent);
    }

    CompositeComponentStackManager ccStackManager =
        CompositeComponentStackManager.getManager(context);
    boolean compcompPushed = pushComponentToEL(ctx, c, ccStackManager);

    if (ProjectStage.Development == context.getApplication().getProjectStage()) {
      ComponentSupport.setTagForComponent(context, c, this.owner.getTag());
    }

    // If this this a naming container, stop generating unique Ids
    // for the repeated tags
    boolean setUniqueIds = false;
    boolean oldUnique = false;
    if (c instanceof NamingContainer) {
      oldUnique = ComponentSupport.setNeedUniqueIds(ctx, false);
      setUniqueIds = true;
    }
    try {
      // first allow c to get populated
      owner.applyNextHandler(ctx, c);
    } finally {
      if (setUniqueIds) ComponentSupport.setNeedUniqueIds(ctx, oldUnique);
    }

    // finish cleaning up orphaned children
    if (componentFound) {
      doOrphanedChildCleanup(ctx, parent, c);
    }

    this.privateOnComponentPopulated(ctx, c);
    owner.onComponentPopulated(ctx, c, parent);
    // add to the tree afterwards
    // this allows children to determine if it's
    // been part of the tree or not yet
    addComponentToView(ctx, parent, c, componentFound);
    adjustIndexOfDynamicChildren(context, c);
    popComponentFromEL(ctx, c, ccStackManager, compcompPushed);
  }