Package org.apache.wicket.markup

Examples of org.apache.wicket.markup.MarkupStream


    if (markup == null)
    {
      throw new MarkupException("Markup not found. Component: " + toString());
    }

    final MarkupStream markupStream = new MarkupStream(markup);

    // Get mutable copy of next tag
    final ComponentTag openTag = markupStream.getTag();
    final ComponentTag tag = openTag.mutable();

    // Call any tag handler
    onComponentTag(tag);

    // If we're an openclose tag
    if (!tag.isOpenClose() && !tag.isOpen())
    {
      // We were something other than <tag> or <tag/>
      markupStream.throwMarkupException("Method renderComponent called on bad markup element: " +
        tag);
    }

    if (tag.isOpenClose() && openTag.isOpen())
    {
      markupStream.throwMarkupException("You can not modify a open tag to open-close: " + tag);
    }

    try
    {
      // Render open tag
      if (getRenderBodyOnly() == false)
      {
        renderComponentTag(tag);
      }
      markupStream.next();

      // Render the body only if open-body-close. Do not render if open-close.
      if (tag.isOpen())
      {
        // Render the body. The default strategy will simply call the component's
View Full Code Here


            .append(isVersioned());
        }

        if (markup != null)
        {
          buffer.append(", markup = ").append(new MarkupStream(getMarkup()).toString());
        }
      }

      buffer.append(']');
View Full Code Here

   * @return The markup stream for this component. Since a Component cannot have a markup stream,
   *         we ask this component's parent to search for it.
   */
  protected final MarkupStream findMarkupStream()
  {
    return new MarkupStream(getMarkup());
  }
View Full Code Here

    // 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))
    {
      ComponentTag tag = stream.getTag();
      if (TagUtils.isWicketHeadTag(tag))
      {
        if (tag.getMarkupClass() == null)
        {
          // find() can still fail an return null => continue the search
          childMarkup = stream.getMarkupFragment().find(child.getId());
        }
      }
      else if (TagUtils.isHeadTag(tag))
      {
        // find() can still fail an return null => continue the search
        childMarkup = stream.getMarkupFragment().find(child.getId());
      }

      // Must be a direct child. We are not interested in grand children
      if (tag.isOpen() && !tag.hasNoCloseTag())
      {
        stream.skipToMatchingCloseTag(tag);
      }
      stream.next();
    }

    return childMarkup;
  }
View Full Code Here

    // reset for each render in case the strategy is re-used
    noMoreWicketHeadTagsAllowed = false;

    // Gracefully getAssociateMarkupStream. Throws no exception in case
    // markup is not found
    final MarkupStream markupStream = container.getAssociatedMarkupStream(false);
    if (markupStream == null)
    {
      return;
    }

    // Position pointer at current (first) header
    noMoreWicketHeadTagsAllowed = false;
    while (nextHeaderMarkup(markupStream) != -1)
    {
      // found <wicket:head>
      String headerId = getHeaderId(container, markupStream);

      // Create a HeaderPartContainer and associate the markup
      HeaderPartContainer headerPart = getHeaderPart(container, headerId,
        markupStream.getMarkupFragment());
      if (headerPart != null)
      {
        // A component's header section must only be added once,
        // no matter how often the same Component has been added
        // to the page or any other container in the hierarchy.
        if (htmlContainer.okToRenderComponent(headerPart.getScope(), headerPart.getId()))
        {
          // make sure the Page is accessible
          headerPart.setParent(htmlContainer);
          headerPart.render();
        }
      }

      // Position the stream after <wicket:head>
      markupStream.skipComponent();
    }
  }
View Full Code Here

   * @param markup
   * @return null, if not found
   */
  private final static IMarkupFragment findPanelTag(final IMarkupFragment markup)
  {
    MarkupStream stream = new MarkupStream(markup);

    while (stream.skipUntil(ComponentTag.class))
    {
      ComponentTag tag = stream.getTag();
      if (tag.isOpen() || tag.isOpenClose())
      {
        if (tag instanceof WicketTag)
        {
          WicketTag wtag = (WicketTag)tag;
          if (wtag.isPanelTag())
          {
            return stream.getMarkupFragment();
          }
        }
        stream.skipToMatchingCloseTag(tag);
      }

      stream.next();
    }

    return null;
  }
View Full Code Here

  private transient MarkupStream markupStream;

  @Override
  public void beforeRender(final Component component)
  {
    final MarkupStream stream = getMarkupStream(component);
    final Response response = component.getResponse();
    stream.setCurrentIndex(0);

    boolean insideBorderMarkup = false;
    while (stream.hasMore())
    {
      MarkupElement elem = stream.get();
      stream.next();
      if (elem instanceof WicketTag)
      {
        WicketTag wTag = (WicketTag)elem;
        if (!insideBorderMarkup)
        {
          if (wTag.isBorderTag() && wTag.isOpen())
          {
            insideBorderMarkup = true;
            continue;
          }
          else
          {
            throw new WicketRuntimeException(
              "Unexpected tag encountered in markup of component border " +
                getClass().getName() + ". Tag: " + wTag.toString() +
                ", expected tag: <wicket:border>");
          }
        }
        else
        {
          if (wTag.isBodyTag())
          {
            break;
          }
          else
          {
            throw new WicketRuntimeException(
              "Unexpected tag encountered in markup of component border " +
                getClass().getName() + ". Tag: " + wTag.toString() +
                ", expected tag: <wicket:body> or </wicket:body>");
          }
        }
      }
      if (insideBorderMarkup)
      {
        response.write(elem.toCharSequence());
      }
    }

    if (!stream.hasMore())
    {
      throw new WicketRuntimeException("Markup for component border " + getClass().getName() +
        " ended prematurely, was expecting </wicket:border>");
    }
  }
View Full Code Here

  }

  @Override
  public void afterRender(final Component component)
  {
    final MarkupStream stream = getMarkupStream(component);
    final Response response = component.getResponse();

    while (stream.hasMore())
    {
      MarkupElement elem = stream.get();
      stream.next();
      if (elem instanceof WicketTag)
      {
        WicketTag wTag = (WicketTag)elem;
        if (wTag.isBorderTag() && wTag.isClose())
        {
View Full Code Here

    {
      IMarkupFragment markup = MarkupFactory.get()
        .newMarkupParser(markupResourceStream)
        .parse();

      return new MarkupStream(markup);
    }
    catch (Exception e)
    {
      throw new WicketRuntimeException(
        "Could not parse markup from markup resource stream: " +
View Full Code Here

    // clear the cache
    childComponent = null;

    // get Child Component. If not "added", ask a resolver to find it.
    childComponent = getChildComponent(new MarkupStream(getMarkup()), container);
    checkChildComponent(childComponent);
  }
View Full Code Here

TOP

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

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.