Package org.apache.wicket.markup

Examples of org.apache.wicket.markup.IMarkupFragment


   */
  // to use it call it from #onInitialize()
  private void createAndAddComponentsForWicketTags()
  {
    // Markup must be available
    IMarkupFragment markup = getMarkup();
    if ((markup != null) && (markup.size() > 1))
    {
      MarkupStream stream = new MarkupStream(markup);

      // Skip the first component tag which already belongs to 'this' container
      if (stream.skipUntil(ComponentTag.class))
View Full Code Here


   */
  @Override
  public IMarkupFragment getMarkup(final MarkupContainer container, final Component child)
  {
    // Get the markup to search for the fragment markup
    IMarkupFragment markup = chooseMarkup(container);
    if (markup == null)
    {
      throw new MarkupException("The fragments markup provider has no associated markup. " +
        "No markup to search for fragment markup with id: " + markupId);
    }

    // Search for the fragment markup
    IMarkupFragment childMarkup = markup.find(markupId);
    if (childMarkup == null)
    {
      // There is one more option if the markup provider has associated markup
      MarkupContainer markupProvider = getMarkupProvider(container);
      Markup associatedMarkup = markupProvider.getAssociatedMarkup();
      if (associatedMarkup != null)
      {
        markup = associatedMarkup;
        if (markup != null)
        {
          childMarkup = markup.find(markupId);
        }
      }
    }

    if (childMarkup == null)
    {
      throw new MarkupNotFoundException("No Markup found for Fragment '" + markupId
          + "' in providing markup container " + getMarkupProvider(container));
    }
    else
    {
      MarkupElement fragmentTag = childMarkup.get(0);
      if ((fragmentTag instanceof WicketTag && ((WicketTag)fragmentTag).isFragementTag()) == false)
      {
        throw new MarkupNotFoundException("Markup found for Fragment '" + markupId
            + "' in providing markup container " + getMarkupProvider(container)
            + " is not a fragment tag");
      }
    }

    if (child == null)
    {
      return childMarkup;
    }

    // search for the child inside the fragment markup
    return childMarkup.find(child.getId());
  }
View Full Code Here

      throw new WicketRuntimeException(
        "Bug: The Wicket internal instance of HtmlHeaderContainer is not connected to a parent");
    }

    // Get the page markup
    IMarkupFragment markup = getPage().getMarkup();
    if (markup == null)
    {
      throw new MarkupException("Unable to get page markup: " + getPage().toString());
    }

    // Find the markup fragment
    MarkupStream stream = new MarkupStream(markup);
    IMarkupFragment headerMarkup = null;
    while (stream.skipUntil(ComponentTag.class) && (headerMarkup == null))
    {
      ComponentTag tag = stream.getTag();
      if (tag.isOpen() || tag.isOpenClose())
      {
View Full Code Here

   *
   * @return first component tag
   */
  private final ComponentTag getMarkupTag()
  {
    IMarkupFragment markup = getMarkup();
    if (markup != null)
    {
      for (int i = 0; i < markup.size(); i++)
      {
        MarkupElement elem = markup.get(i);
        if (elem instanceof ComponentTag)
        {
          return (ComponentTag)elem;
        }
      }
View Full Code Here

   * Performs a render of this component as part of a Page level render process.
   */
  private final void internalRender()
  {
    // Make sure there is a markup available for the Component
    IMarkupFragment markup = getMarkup();
    if (markup == null)
    {
      throw new MarkupNotFoundException("Markup not found for Component: " + toString());
    }

    // MarkupStream is an Iterator for the markup
    MarkupStream markupStream = new MarkupStream(markup);

    // Flag: we started the render process
    markRendering(true);

    MarkupElement elem = markup.get(0);
    if (elem instanceof ComponentTag)
    {
      // Guarantee that the markupStream is set and determineVisibility not yet tested
      // See WICKET-2049
      ((ComponentTag)elem).onBeforeRender(this, markupStream);
View Full Code Here

   * onComponentTag() is called to allow the component to mutate the start tag. The method
   * onComponentTagBody() is then called to permit the component to render its body.
   */
  public final void internalRenderComponent()
  {
    final IMarkupFragment markup = getMarkup();
    if (markup == null)
    {
      throw new MarkupException("Markup not found. Component: " + toString());
    }

View Full Code Here

      @Override
      public void component(MarkupContainer resolvingContainer, IVisit<IMarkupFragment> visit)
      {
        if (resolvingContainer instanceof IComponentResolver)
        {
          IMarkupFragment childMarkup = resolvingContainer.getMarkup(child);

          if (childMarkup != null && childMarkup.size() > 0)
          {
            IComponentResolver componentResolver = (IComponentResolver)resolvingContainer;

            MarkupStream stream = new MarkupStream(childMarkup);
View Full Code Here

    }

    @Override
    public IMarkupFragment getMarkup()
    {
      IMarkupFragment calculatedMarkup = null;
      if (pageMarkup == null)
      {
        IMarkupFragment markup = super.getMarkup();
        if (markup != null && markup != Markup.NO_MARKUP)
        {
          calculatedMarkup = markup;
          pageMarkup = markup;
        }
View Full Code Here

  public void onComponentTag(final Component component, final ComponentTag tag)
  {
    super.onComponentTag(component, tag);

    // Copy attributes from <wicket:XXX> to the "calling" tag
    IMarkupFragment markup = ((MarkupContainer)component).getMarkup(null);
    String namespace = markup.getMarkupResourceStream().getWicketNamespace() + ":";

    MarkupElement elem = markup.get(0);
    if (elem instanceof ComponentTag)
    {
      ComponentTag panelTag = (ComponentTag)elem;
      for (String key : panelTag.getAttributes().keySet())
      {
        // exclude "wicket:XX" attributes
        if (key.startsWith(namespace) == false)
        {
          tag.append(key, panelTag.getAttribute(key), ", ");
        }
      }
    }
    else
    {
      throw new MarkupException(markup.getMarkupResourceStream(),
        "Expected a Tag but found raw markup: " + elem.toString());
    }
  }
View Full Code Here

   */
  public IMarkupFragment findMarkupInAssociatedFileHeader(final MarkupContainer container,
    final Component child)
  {
    // Get the associated markup
    IMarkupFragment markup = container.getAssociatedMarkup();
    IMarkupFragment childMarkup = null;

    // MarkupStream is good at searching markup
    MarkupStream stream = new MarkupStream(markup);
    while (stream.skipUntil(ComponentTag.class) && (childMarkup == null))
    {
View Full Code Here

TOP

Related Classes of org.apache.wicket.markup.IMarkupFragment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.