Examples of MarkupElement


Examples of org.apache.wicket.markup.MarkupElement

    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

Examples of org.apache.wicket.markup.MarkupElement

    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

Examples of org.apache.wicket.markup.MarkupElement

    // 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

Examples of org.apache.wicket.markup.MarkupElement

   */
  private final HeaderPartContainer getHeaderPart(final WebMarkupContainer container,
    final String id, final IMarkupFragment markup)
  {
    // Create a HtmlHeaderContainer for the header tag found
    final MarkupElement element = markup.get(0);
    if (element instanceof WicketTag)
    {
      final WicketTag wTag = (WicketTag)element;
      if ((wTag.isHeadTag() == true) && (wTag.getNamespace() != null))
      {
View Full Code Here

Examples of org.apache.wicket.markup.MarkupElement

    {
      return -1;
    }

    // Scan the markup for <wicket:head>.
    MarkupElement elem = associatedMarkupStream.get();
    while (elem != null)
    {
      if (elem instanceof WicketTag)
      {
        WicketTag tag = (WicketTag)elem;
View Full Code Here

Examples of org.apache.wicket.markup.MarkupElement

    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())
    {
View Full Code Here

Examples of org.apache.wicket.markup.MarkupElement

    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())
        {
          break;
        }
        else
        {
          throw new WicketRuntimeException(
            "Unexpected tag encountered in markup of component border " +
              getClass().getName() + ". Tag: " + wTag.toString() +
              ", expected tag: </wicket:border>");
        }
      }
      response.write(elem.toCharSequence());
    }
  }
View Full Code Here

Examples of org.apache.wicket.markup.MarkupElement

    // Find <wicket:border>
    IMarkupFragment borderMarkup = null;
    for (int i = 0; i < markup.size(); i++)
    {
      MarkupElement elem = markup.get(i);
      if (TagUtils.isWicketBorderTag(elem))
      {
        borderMarkup = new MarkupFragment(markup, i);
        break;
      }
View Full Code Here

Examples of org.apache.wicket.markup.MarkupElement

  {
    // Get associated markup file for the Border or Panel component
    final MarkupStream associatedMarkupStream = new MarkupStream(getMarkup(null));

    // Get open tag in associated markup of border component
    MarkupElement elem = associatedMarkupStream.get();
    if ((elem instanceof ComponentTag) == false)
    {
      associatedMarkupStream.throwMarkupException("Expected the open tag. " +
        exceptionMessage);
    }
View Full Code Here

Examples of org.apache.wicket.markup.MarkupElement

   * @return true, if element was rendered as RawMarkup
   */
  protected boolean renderNext(final MarkupStream markupStream)
  {
    // Get the current markup element
    final MarkupElement element = markupStream.get();

    // If it's a tag like <wicket..> or <span wicket:id="..." >
    if ((element instanceof ComponentTag) && !markupStream.atCloseTag())
    {
      // Get element as tag
      final ComponentTag tag = (ComponentTag)element;

      // Get component id
      final String id = tag.getId();

      // Get the component for the id from the given container
      Component component = get(id);
      if (component == null)
      {
        component = ComponentResolvers.resolve(this, markupStream, tag, null);
        if ((component != null) && (component.getParent() == null))
        {
          autoAdd(component, markupStream);
        }
        else if (component != null)
        {
          component.setMarkup(markupStream.getMarkupFragment());
        }
      }

      // Failed to find it?
      if (component != null)
      {
        component.render();
      }
      else if (tag.getFlag(ComponentTag.RENDER_RAW))
      {
        // No component found, but "render as raw markup" flag found
        getResponse().write(element.toCharSequence());
        return true;
      }
      else
      {
        if (tag instanceof WicketTag)
        {
          if (((WicketTag)tag).isChildTag())
          {
            markupStream.throwMarkupException("Found " + tag.toString() +
              " but no <wicket:extend>. Container: " + toString());
          }
          else
          {
            markupStream.throwMarkupException("Failed to handle: " +
              tag.toString() +
              ". It might be that no resolver has been registered to handle this special tag. " +
              " But it also could be that you declared wicket:id=" + id +
              " in your markup, but that you either did not add the " +
              "component to your page at all, or that the hierarchy does not match. " +
              "Container: " + toString());
          }
        }

        List<String> names = findSimilarComponents(id);

        // No one was able to handle the component id
        StringBuilder msg = new StringBuilder(500);
        msg.append("Unable to find component with id '");
        msg.append(id);
        msg.append("' in ");
        msg.append(this.toString());
        msg.append("\n\tExpected: '");
        msg.append(getPageRelativePath());
        msg.append(PATH_SEPARATOR);
        msg.append(id);
        msg.append("'.\n\tFound with similar names: '");
        msg.append(Strings.join("', ", names));
        msg.append('\'');

        log.error(msg.toString());
        markupStream.throwMarkupException(msg.toString());
      }
    }
    else
    {
      // Render as raw markup
      getResponse().write(element.toCharSequence());
      return true;
    }

    return false;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.