Package org.apache.wicket.markup

Examples of org.apache.wicket.markup.ComponentTag


    for (; index < markup.size(); index++)
    {
      MarkupElement element = markup.get(index);
      if (element instanceof ComponentTag)
      {
        ComponentTag tag = (ComponentTag)element;

        if (tag.isOpen() || tag.isOpenClose())
        {
          DequeueTagAction action = canDequeueTag(tag);
          switch (action)
          {
            case IGNORE :
              continue;
            case DEQUEUE :
              index++;
              return tag;
            case SKIP : // skip to close tag
              boolean found = false;
              for (; index < markup.size(); index++)
              {
                if ((markup.get(index) instanceof ComponentTag)
                  && markup.get(index).closes(tag))
                {
                  found = true;
                  break;
                }
              }
              if (!found)
              {
                throw new IllegalStateException(
                  String.format("Could not find close tag for tag '%s' in markup: %s ",
                      tag, markup));
              }

          }
        }
        else
        {
          // closed tag
          ComponentTag open = tag.isClose() ? tag.getOpenTag() : tag;

          if (skipFirst && first != null && open == first)
          {
            continue;
          }
View Full Code Here


   *
   * @return
   */
  public boolean isAtOpenOrOpenCloseTag()
  {
    ComponentTag tag = peekTag();
    return tag != null && (tag.isOpen() || tag.isOpenClose());
  }
View Full Code Here

        {
          IMarkupFragment containerMarkup = container.getMarkup();
          MarkupStream containerMarkupStream = new MarkupStream(containerMarkup);
          if (containerMarkupStream.atTag())
          {
            ComponentTag tag = containerMarkupStream.getTag();
            Class<? extends Page> clazz = (Class<? extends Page>)tag.getMarkupClass();
            if (clazz != null)
            {
              // Href is relative. Resolve the url given relative to
              // the current page
              className = Packages.absolutePath(clazz, pathInfo.path);
View Full Code Here

        oldClasses.add("one");
        oldClasses.add("two");
        return oldClasses;
      }
    };
    ComponentTag tag = createTag();

    Map<String, Object> attributes = tag.getAttributes();

    cam.replaceAttributeValue(null, tag);

    String classes = (String) attributes.get(cam.getAttribute());
    assertEquals("one two", classes);
View Full Code Here

        oldClasses.remove("two");
        oldClasses.add("three");
        return oldClasses;
      }
    };
    ComponentTag tag = createTag();

    Map<String, Object> attributes = tag.getAttributes();
    attributes.put(cam.getAttribute(), "one two    ");

    cam.replaceAttributeValue(null, tag);

    String classes = (String) attributes.get(cam.getAttribute());
View Full Code Here

        oldClasses.remove("one");
        oldClasses.remove("two");
        return oldClasses;
      }
    };
    ComponentTag tag = createTag();

    Map<String, Object> attributes = tag.getAttributes();
    attributes.put(cam.getAttribute(), "two    one");

    cam.replaceAttributeValue(null, tag);

    String classes = (String) attributes.get(cam.getAttribute());
View Full Code Here

  }

  private ComponentTag createTag()
  {
    XmlTag xmlTag = new XmlTag();
    ComponentTag tag = new ComponentTag(xmlTag);
    tag.setId("ClassAttributeModifier");
    tag.setName("test");
    return tag;
  }
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())
      {
        if (getFlag(FLAG_OUTPUT_MARKUP_ID))
        {
          log.warn(String.format(
            "Markup id set on a component that renders its body only. "
              + "Markup id: %s, component id: %s.", getMarkupId(), getId()));
        }
        if (getFlag(FLAG_PLACEHOLDER))
        {
          log.warn(String.format(
            "Placeholder tag set on a component that renders its body only. "
              + "Component id: %s.", getId()));
        }
      }
      else
      {
        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 (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

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.