Package org.apache.wicket.markup

Examples of org.apache.wicket.markup.ComponentTag


  /**
   * @return The 'id' attribute from the associated markup tag
   */
  public final String getMarkupIdFromMarkup()
  {
    ComponentTag tag = getMarkupTag();
    if (tag != null)
    {
      String id = tag.getAttribute("id");
      if (Strings.isEmpty(id) == false)
      {
        return id.trim();
      }
    }
View Full Code Here


   *
   * @return markup attributes
   */
  public final ValueMap getMarkupAttributes()
  {
    ComponentTag tag = getMarkupTag();
    if (tag != null)
    {
      ValueMap attrs = new ValueMap(tag.getAttributes());
      attrs.makeImmutable();
      return attrs;
    }
    return ValueMap.EMPTY_MAP;
  }
View Full Code Here

    }

    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
        // onComponentTagBody() implementation.
        getMarkupSourcingStrategy().onComponentTagBody(this, markupStream, tag);
      }

      // Render close tag
      if (tag.isOpen())
      {
        if (openTag.isOpen())
        {
          renderClosingComponentTag(markupStream, tag, getRenderBodyOnly());
        }
        else if (getRenderBodyOnly() == false)
        {
          if (needToRenderTag(openTag))
          {
            // Close the manually opened tag. And since the user might have changed the
            // tag name ...
            getResponse().write(tag.syntheticCloseTagString());
          }
        }
      }
    }
    catch (WicketRuntimeException wre)
View Full Code Here

  protected final void replaceComponentTagBody(final MarkupStream markupStream,
    final ComponentTag tag, final CharSequence body)
  {
    // The tag might have been changed from open-close to open. Hence
    // we'll need what was in the markup itself
    ComponentTag markupOpenTag = null;

    // If tag has a body
    if (tag.isOpen())
    {
      // Get what tag was in the markup; not what the user it might
      // have changed it to.
      markupOpenTag = markupStream.getPreviousTag();

      // If it was an open tag in the markup as well, than ...
      if (markupOpenTag.isOpen())
      {
        // skip any raw markup in the body
        markupStream.skipRawMarkup();
      }
    }

    if (body != null)
    {
      // Write the new body
      getResponse().write(body);
    }

    // If we had an open tag (and not an openclose tag) and we found a
    // close tag, we're good
    if (tag.isOpen())
    {
      // If it was an open tag in the markup, than there must be
      // a close tag as well.
      if ((markupOpenTag != null) && markupOpenTag.isOpen() && !markupStream.atCloseTag())
      {
        // There must be a component in this discarded body
        markupStream.throwMarkupException("Expected close tag for '" + markupOpenTag +
          "' Possible attempt to embed component(s) '" + markupStream.get() +
          "' in the body of this component which discards its body");
View Full Code Here

      if (contains(name))
      {
        if (onFound(tag))
        {
          next = new ComponentTag(tag.getName(), TagType.CLOSE);
          next.setNamespace(tag.getNamespace());
          next.setOpenTag(tag);
          next.setModified(true);
        }
      }
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 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.");
          }
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

  /**
   * @return The 'id' attribute from the associated markup tag
   */
  public final String getMarkupIdFromMarkup()
  {
    ComponentTag tag = getMarkupTag();
    if (tag != null)
    {
      String id = tag.getAttribute("id");
      if (Strings.isEmpty(id) == false)
      {
        return id.trim();
      }
    }
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.