Package org.apache.wicket.markup

Examples of org.apache.wicket.markup.ComponentTag


  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 (tag.isOpen() && (tag.getId() != null) && !(tag instanceof WicketTag) &&
        !tag.isAutoComponentTag())
      {
        for (int i = enclosures.size() - 1; i >= 0; i--)
        {
          ComponentTag lastEnclosure = enclosures.get(i);
          String attr = getInlineEnclosureAttribute(lastEnclosure);
          if (Strings.isEmpty(attr) == true)
          {
            lastEnclosure.getAttributes().put(INLINE_ENCLOSURE_ATTRIBUTE_NAME,
              tag.getId());
            lastEnclosure.setModified(true);
          }
        }
      }
      else if (tag.isClose() && tag.closes(enclosures.peek()))
      {
        ComponentTag lastEnclosure = enclosures.pop();
        String attr = getInlineEnclosureAttribute(lastEnclosure);
        if (Strings.isEmpty(attr) == true)
        {
          throw new ParseException("Did not find any child for InlineEnclosure. Tag:" +
            lastEnclosure.toString(), tag.getPos());
        }
      }
    }

    return tag;
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

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

      }

      // Get the <span wicket:id="myBorder"> markup and render that instead
      IMarkupFragment markup = Border.this.getMarkup();
      MarkupStream stream = new MarkupStream(markup);
      ComponentTag tag = stream.getTag();
      stream.next();

      super.onComponentTagBody(stream, tag);
    }
View Full Code Here

      // Skip <wicket:border>
      stream.next();

      while (stream.skipUntil(ComponentTag.class))
      {
        ComponentTag tag = stream.getTag();
        if (tag.isOpen() || tag.isOpenClose())
        {
          if (TagUtils.isWicketBodyTag(tag))
          {
            return stream.getMarkupFragment();
          }
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

   *
   * @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

  {
    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 (tagName.equalsIgnoreCase(wtag.getName()))
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.