Package org.apache.wicket.markup

Examples of org.apache.wicket.markup.ComponentTag


    // 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();
    }
View Full Code Here


          noMoreWicketHeadTagsAllowed = true;
        }
      }
      else if (elem instanceof ComponentTag)
      {
        ComponentTag tag = (ComponentTag)elem;
        // wicket:head must be before </head>
        // @TODO why??
        if (tag.isClose() && TagUtils.isHeadTag(tag))
        {
          noMoreWicketHeadTagsAllowed = true;
        }
        // wicket:head must be before <body>
        // @TODO why??
        else if (tag.isOpen() && TagUtils.isBodyTag(tag))
        {
          noMoreWicketHeadTagsAllowed = true;
        }
      }
      elem = associatedMarkupStream.next();
View Full Code Here

      associatedMarkupStream.throwMarkupException("Expected the open tag. " +
        exceptionMessage);
    }

    // Check for required open tag name
    ComponentTag associatedMarkupOpenTag = (ComponentTag)elem;
    if (!((associatedMarkupOpenTag != null) && associatedMarkupOpenTag.isOpen() && (associatedMarkupOpenTag instanceof WicketTag)))
    {
      associatedMarkupStream.throwMarkupException(exceptionMessage);
    }

    try
View Full Code Here

    // 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>");
          }
          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 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.");
          }
View Full Code Here

  {
    if ((markupStream != null) && (markupStream.getCurrentIndex() > 0))
    {
      // If the original tag has been changed from open-close to open-body-close, than we are
      // done. Other components, e.g. BorderBody, rely on this method being called.
      ComponentTag origOpenTag = (ComponentTag)markupStream.get(markupStream.getCurrentIndex() - 1);
      if (origOpenTag.isOpenClose())
      {
        return;
      }
    }
View Full Code Here

      }

      // Search for <wicket:xxx> in the remaining markup and try to resolve the component
      while (stream.skipUntil(ComponentTag.class))
      {
        ComponentTag tag = stream.getTag();
        if (tag.isOpen() || tag.isOpenClose())
        {
          if (tag instanceof WicketTag)
          {
            Component component = ComponentResolvers.resolve(this, stream, tag, null);
            if ((component != null) && (component.getParent() == null))
            {
              if (component.getId().equals(tag.getId()) == false)
              {
                // make sure we are able to get() the component during rendering
                tag.setId(component.getId());
                tag.setModified(true);
              }
              add(component);
            }
          }

          if (tag.isOpen())
          {
            stream.skipToMatchingCloseTag(tag);
          }
        }
        stream.next();
View Full Code Here

    // Skip the body markup making sure it contains only raw markup
    super.onComponentTagBody(component, markupStream, openTag);

    // Get the fragments open tag
    MarkupStream stream = new MarkupStream(getMarkup((MarkupContainer)component, null));
    ComponentTag fragmentOpenTag = stream.getTag();

    // if it is an open close tag, skip this fragment.
    if (!fragmentOpenTag.isOpenClose())
    {
      // We'll completely ignore the fragments open tag. It'll not be rendered
      stream.next();

      // Render the body of the fragment
View Full Code Here

    // 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())
      {
        if (tag instanceof WicketTag)
        {
          WicketTag wtag = (WicketTag)tag;
          if (wtag.isHeadTag() || wtag.isHeaderItemsTag())
          {
            headerMarkup = stream.getMarkupFragment();
            break;
          }
        }
        else if (tag.getName().equalsIgnoreCase("head") && tag.isAutoComponentTag())
        {
          headerMarkup = stream.getMarkupFragment();
          break;
        }
      }
View Full Code Here

        else if (tag.isClose())
        {
          if (foundHeaderItemsTag)
          {
            // revert the settings from above
            ComponentTag headOpenTag = tag.getOpenTag();
            // change the id because it is special. See HtmlHeaderResolver
            headOpenTag.setId(HEADER_ID + "-Ignored");
            headOpenTag.setAutoComponentTag(false);
            headOpenTag.setModified(false);
            headOpenTag.setFlag(ComponentTag.RENDER_RAW, true);
          }

          foundClosingHead = true;
        }
View Full Code Here

   * Insert <head> open and close tag (with empty body) to the current position.
   */
  private void insertHeadTag()
  {
    // Note: only the open-tag must be a AutoComponentTag
    final ComponentTag openTag = new ComponentTag(HEAD, TagType.OPEN);
    openTag.setId(HEADER_ID);
    openTag.setAutoComponentTag(true);
    openTag.setModified(true);

    final ComponentTag closeTag = new ComponentTag(HEAD, TagType.CLOSE);
    closeTag.setOpenTag(openTag);
    closeTag.setModified(true);

    // insert the tags into the markup stream
    markup.addMarkupElement(openTag);
    markup.addMarkupElement(closeTag);
  }
View Full Code Here

TOP

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

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.