Package org.apache.wicket.markup

Examples of org.apache.wicket.markup.IMarkupFragment


   * @return true, if it has been moved
   */
  private boolean moveComponentToItsRealParent()
  {
    MarkupContainer parent = getParent();
    IMarkupFragment markup = getMarkup();
    if ((parent != null) && (markup != null))
    {
      IMarkupFragment parentMarkup = parent.getMarkup(null);
      if ((parentMarkup != null) && (markup != parentMarkup))
      {
        // The component's markup must be in the same file as its parent
        if (markup.getMarkupResourceStream() == parentMarkup.getMarkupResourceStream())
        {
          MarkupStream stream = new MarkupStream(markup);
          stream.skipUntil(ComponentTag.class);
          ComponentTag openTag = stream.getTag();
          if (openTag != null)
          {
            MarkupStream parentStream = new MarkupStream(parentMarkup);
            if (parentStream.skipUntil(ComponentTag.class))
            {
              parentStream.next();
            }

            Stack<ComponentTag> stack = new Stack<ComponentTag>();
            while (parentStream.skipUntil(ComponentTag.class))
            {
              ComponentTag tag = parentStream.getTag();
              if (openTag == tag)
              {
                if (stack.isEmpty() == false)
                {
                  // This tag belong to the real parent
                  final ComponentTag lastTag = stack.pop();
                  parent.visitChildren(MarkupContainer.class,
                    new IVisitor<MarkupContainer, Void>()
                    {
                      public void component(final MarkupContainer component,
                        final IVisit<Void> visit)
                      {
                        IMarkupFragment m = component.getMarkup();
                        MarkupStream ms = new MarkupStream(m);
                        ms.skipUntil(ComponentTag.class);
                        if (ms.hasMore() && (lastTag == ms.getTag()))
                        {
                          component.add(Component.this);
View Full Code Here


   *
   * @return first component tag
   */
  private final ComponentTag getMarkupTag()
  {
    IMarkupFragment markup = getMarkup();
    if (markup != null)
    {
      for (int i = 0; i < markup.size(); i++)
      {
        MarkupElement elem = markup.get(i);
        if (elem instanceof ComponentTag)
        {
          return (ComponentTag)elem;
        }
      }
View Full Code Here

   * Performs a render of this component as part of a Page level render process.
   */
  private final void internalRender()
  {
    // Make sure there is a markup available for the Component
    IMarkupFragment markup = getMarkup();
    if (markup == null)
    {
      throw new MarkupNotFoundException("Markup not found for Component: " + toString());
    }

    // MarkupStream is an Iterator for the markup
    MarkupStream markupStream = new MarkupStream(markup);

    // Flag: we stated the render process
    markRendering(true);

    MarkupElement elem = markup.get(0);
    if (elem instanceof ComponentTag)
    {
      // Guarantee that the markupStream is set and determineVisibility not yet tested
      // See WICKET-2049
      ((ComponentTag)elem).onBeforeRender(this, markupStream);
View Full Code Here

   * onComponentTag() is called to allow the component to mutate the start tag. The method
   * onComponentTagBody() is then called to permit the component to render its body.
   */
  public final void internalRenderComponent()
  {
    final IMarkupFragment markup = getMarkup();
    if (markup == null)
    {
      throw new MarkupException("Markup not found. Component: " + toString());
    }

View Full Code Here

   *            If true, throw an exception, if markup could not be found
   * @return A stream of MarkupElement elements
   */
  public MarkupStream getAssociatedMarkupStream(final boolean throwException)
  {
    IMarkupFragment markup = getAssociatedMarkup();

    // If we found markup for this container
    if (markup != null)
    {
      return new MarkupStream(markup);
View Full Code Here

   */
  public IMarkupFragment getAssociatedMarkup()
  {
    try
    {
      IMarkupFragment markup = MarkupFactory.get().getMarkup(this, false);

      // If we found markup for this container
      if ((markup != null) && (markup != Markup.NO_MARKUP))
      {
        return markup;
View Full Code Here

   * Automatically create components for <wicket:xxx> tag.
   */
  private void createAndAddComponentsForWicketTags()
  {
    // Markup must be available
    IMarkupFragment markup = getMarkup();
    if ((markup != null) && (markup.size() > 1))
    {
      MarkupStream stream = new MarkupStream(markup);

      // Skip the first component tag which already belongs to 'this' container
      if (stream.skipUntil(ComponentTag.class))
View Full Code Here

    // Set content type based on markup type for page
    response.setContentType(getMarkupType().getMimeType() + "; charset=" + encoding);

    // Write out an xml declaration if the markup stream and settings allow
    final IMarkupFragment markup = getMarkup();
    if ((markup != null) && (markup.getMarkupResourceStream().getXmlDeclaration() != null) &&
      (application.getMarkupSettings().getStripXmlDeclarationFromOutput() == false))
    {
      // Gwyn - Wed, 21 May 2008 12:23:41
      // If the xml declaration in the markup used double-quotes, use them in the output too
      // Whether it should be or not, sometimes it's significant...
      final String quoteChar = (markup.getMarkupResourceStream()
        .getXmlDeclaration()
        .indexOf('\"') == -1) ? "'" : "\"";

      response.write("<?xml version=");
      response.write(quoteChar);
View Full Code Here

    }

    @Override
    public IMarkupFragment getMarkup()
    {
      IMarkupFragment calculatedMarkup = null;
      if (pageMarkup == null)
      {
        IMarkupFragment markup = super.getMarkup();
        if (markup != null && markup != Markup.NO_MARKUP)
        {
          calculatedMarkup = markup;
          pageMarkup = markup;
        }
View Full Code Here

   *
   * @return first component tag
   */
  private final ComponentTag getMarkupTag()
  {
    IMarkupFragment markup = getMarkup();
    if (markup != null)
    {
      for (int i = 0; i < markup.size(); i++)
      {
        MarkupElement elem = markup.get(i);
        if (elem instanceof ComponentTag)
        {
          return (ComponentTag)elem;
        }
      }
View Full Code Here

TOP

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

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.