Package org.apache.wicket.markup

Examples of org.apache.wicket.markup.MarkupElement


    stream.setCurrentIndex(0);

    boolean insideBorderMarkup = false;
    while (stream.hasMore())
    {
      MarkupElement e = stream.next();
      if (e instanceof WicketTag)
      {
        WicketTag wt = (WicketTag)e;
        if (!insideBorderMarkup)
        {
          if (wt.isBorderTag() && wt.isOpen())
          {
            insideBorderMarkup = true;
            continue;
          }
          else
          {
            throw new WicketRuntimeException(
              "Unexpected tag encountered in markup of component border " +
                getClass().getName() + ". Tag: " + wt.toString() +
                ", expected tag: <wicket:border>");
          }
        }
        else
        {
          if (wt.isBodyTag())
          {
            break;
          }
          else
          {
            throw new WicketRuntimeException(
              "Unexpected tag encountered in markup of component border " +
                getClass().getName() + ". Tag: " + wt.toString() +
                ", expected tag: <wicket:body> or </wicket:body>");
          }
        }
      }
      if (insideBorderMarkup)
      {
        response.write(e.toCharSequence());
      }
    }

    if (!stream.hasMore())
    {
View Full Code Here


    final MarkupStream stream = getMarkupStream(component);
    final Response response = component.getResponse();

    while (stream.hasMore())
    {
      MarkupElement e = stream.next();
      if (e instanceof WicketTag)
      {
        WicketTag wt = (WicketTag)e;
        if (wt.isBorderTag() && wt.isClose())
        {
          break;
        }
        else
        {
          throw new WicketRuntimeException(
            "Unexpected tag encountered in markup of component border " +
              getClass().getName() + ". Tag: " + wt.toString() +
              ", expected tag: </wicket:border>");
        }
      }
      response.write(e.toCharSequence());
    }
  }
View Full Code Here

   */
  public MarkupElement nextTag() throws ParseException
  {
    if (next != null)
    {
      MarkupElement tmp = next;
      next = null;
      return tmp;
    }

    ComponentTag tag = nextComponentTag();
View Full Code Here

   *            The markup stream
   */
  private final void renderNext(final MarkupStream markupStream)
  {
    // Get the current markup element
    final MarkupElement element = markupStream.get();

    // If it 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
      final Component component = get(id);

      // Failed to find it?
      if (component != null)
      {
        component.render(markupStream);
      }
      else
      {
        // 2rd try: Components like Border and Panel might implement
        // the ComponentResolver interface as well.
        MarkupContainer container = this;
        while (container != null)
        {
          if (container instanceof IComponentResolver)
          {
            if (((IComponentResolver)container).resolve(this, markupStream, tag))
            {
              return;
            }
          }

          container = container.findParent(MarkupContainer.class);
        }

        // 3rd try: Try application's component resolvers
        final List componentResolvers = getApplication().getPageSettings()
            .getComponentResolvers();
        final Iterator iterator = componentResolvers.iterator();
        while (iterator.hasNext())
        {
          final IComponentResolver resolver = (IComponentResolver)iterator.next();
          if (resolver.resolve(this, markupStream, tag))
          {
            return;
          }
        }

        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());
          }
        }

        // No one was able to handle the component id
        markupStream.throwMarkupException("Unable to find component with id '" + id +
            "' in " + this + ". This means 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.");
      }
    }
    else
    {
      // Render as raw markup
      if (log.isDebugEnabled())
      {
        log.debug("Rendering raw markup");
      }
      getResponse().write(element.toCharSequence());
      markupStream.next();
    }
  }
View Full Code Here

   */
  private int requiresBaseMarkup(final Markup markup)
  {
    for (int i = 0; i < markup.size(); i++)
    {
      MarkupElement elem = markup.get(i);
      if (elem instanceof WicketTag)
      {
        WicketTag wtag = (WicketTag)elem;
        if (wtag.isExtendTag())
        {
View Full Code Here

      try
      {
        XmlPullParser parser = new XmlPullParser();
        parser.parse(markup);

        MarkupElement elm = null;
        XmlTag openTag = null;
        XmlTag closeTag = null;
        int level = 0;
        while ((elm = parser.nextTag()) != null && closeTag == null)
        {
View Full Code Here

   *            The markup stream
   */
  private final void renderNext(final MarkupStream markupStream)
  {
    // Get the current markup element
    final MarkupElement element = markupStream.get();

    // If it 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
      final Component component = get(id);

      // Failed to find it?
      if (component != null)
      {
        component.render(markupStream);
      }
      else
      {
        // 2rd try: Components like Border and Panel might implement
        // the ComponentResolver interface as well.
        MarkupContainer container = this;
        while (container != null)
        {
          if (container instanceof IComponentResolver)
          {
            if (((IComponentResolver)container).resolve(this, markupStream, tag))
            {
              return;
            }
          }

          container = container.findParent(MarkupContainer.class);
        }

        // 3rd try: Try application's component resolvers
        final List<IComponentResolver> componentResolvers = getApplication().getPageSettings()
          .getComponentResolvers();
        final Iterator<IComponentResolver> iterator = componentResolvers.iterator();
        while (iterator.hasNext())
        {
          final IComponentResolver resolver = iterator.next();
          if (resolver.resolve(this, markupStream, tag))
          {
            return;
          }
        }

        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());
          }
        }

        // No one was able to handle the component id
        markupStream.throwMarkupException("Unable to find component with id '" + id +
          "' in " + this + ". This means 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.");
      }
    }
    else
    {
      // Render as raw markup
      if (log.isDebugEnabled())
      {
        log.debug("Rendering raw markup");
      }
      getResponse().write(element.toCharSequence());
      markupStream.next();
    }
  }
View Full Code Here

      // child component and save their tag index
      if (!tag.isOpenClose())
      {
        while (markupStream.hasMore() && !markupStream.get().closes(openTag))
        {
          MarkupElement element = markupStream.get();
          // If it a tag like <wicket..> or <span wicket:id="..." >
          if ((element instanceof ComponentTag) && !markupStream.atCloseTag())
          {
            String id = ((ComponentTag)element).getId();
View Full Code Here

        tag = null;
      }

      while (markupStream.hasMore())
      {
        final MarkupElement cursor = markupStream.next();

        if (cursor.closes(parent))
        {
          // parent close tag found, we are done
          break;
        }

        if (tag != null && cursor.closes(tag))
        {
          // child tag is closed, next tag is either parent-close or next direct child
          tag = null;
        }
        else if (tag == null && cursor instanceof ComponentTag)
View Full Code Here

   *            The markup stream
   */
  private final void renderNext(final MarkupStream markupStream)
  {
    // Get the current markup element
    final MarkupElement element = markupStream.get();

    // If it 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
      final Component component = get(id);

      // Failed to find it?
      if (component != null)
      {
        component.render(markupStream);
      }
      else
      {
        // 2rd try: Components like Border and Panel might implement
        // the ComponentResolver interface as well.
        MarkupContainer container = this;
        while (container != null)
        {
          if (container instanceof IComponentResolver)
          {
            if (((IComponentResolver)container).resolve(this, markupStream, tag))
            {
              return;
            }
          }

          container = container.findParent(MarkupContainer.class);
        }

        // 3rd try: Try application's component resolvers
        final List componentResolvers = getApplication().getPageSettings()
          .getComponentResolvers();
        final Iterator iterator = componentResolvers.iterator();
        while (iterator.hasNext())
        {
          final IComponentResolver resolver = (IComponentResolver)iterator.next();
          if (resolver.resolve(this, markupStream, tag))
          {
            return;
          }
        }

        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());
          }
        }

        // No one was able to handle the component id
        markupStream.throwMarkupException("Unable to find component with id '" + id +
          "' in " + this + ". This means 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.");
      }
    }
    else
    {
      // Render as raw markup
      if (log.isDebugEnabled())
      {
        log.debug("Rendering raw markup");
      }
      getResponse().write(element.toCharSequence());
      markupStream.next();
    }
  }
View Full Code Here

TOP

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

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.