Package org.apache.wicket.markup

Examples of org.apache.wicket.markup.IMarkupFragment


   */
  @Override
  public IMarkupFragment getMarkup(final MarkupContainer container, final Component child)
  {
    // Get the markup to search for the fragment markup
    IMarkupFragment markup = chooseMarkup(container);
    if (markup == null)
    {
      throw new MarkupException("The fragments markup provider has no associated markup. " +
        "No markup to search for fragment markup with id: " + markupId);
    }

    // Search for the fragment markup
    IMarkupFragment childMarkup = markup.find(markupId);
    if (childMarkup == null)
    {
      // There is one more option if the markup provider has associated markup
      MarkupContainer markupProvider = getMarkupProvider(container);
      Markup associatedMarkup = markupProvider.getAssociatedMarkup();
      if (associatedMarkup != null)
      {
        markup = associatedMarkup;
        if (markup != null)
        {
          childMarkup = markup.find(markupId);
        }
      }
    }

    if (childMarkup == null)
    {
      throw new MarkupNotFoundException("No Markup found for Fragment " + markupId +
        " in providing markup container " + getMarkupProvider(container));
    }
    else
    {
      MarkupElement fragmentTag = childMarkup.get(0);
      if ((fragmentTag instanceof WicketTag && ((WicketTag)fragmentTag).isFragmentTag()) == false)
      {
        throw new MarkupNotFoundException("Markup found for Fragment '" + markupId
          + "' in providing markup container " + getMarkupProvider(container)
          + " is not a <wicket:fragment> tag");
      }
    }

    if (child == null)
    {
      return childMarkup;
    }

    // search for the child inside the fragment markup
    return childMarkup.find(child.getId());
  }
View Full Code Here


  @Override
  public IMarkupFragment getMarkup(final MarkupContainer container, final Component child)
  {
    // If the sourcing strategy did not provide one, than ask the component.
    // Get the markup for the container
    IMarkupFragment markup = container.getMarkup();
    if (markup == null)
    {
      return null;
    }

    if (child == null)
    {
      return markup;
    }

    // Find the child's markup
    markup = markup.find(child.getId());
    if (markup != null)
    {
      return markup;
    }
View Full Code Here

   * @see org.apache.wicket.MarkupContainer#getMarkup(org.apache.wicket.Component)
   */
  @Override
  public IMarkupFragment getMarkup(final Component child)
  {
    IMarkupFragment markup = null;

    // Get the markup provider
    MarkupContainer provider = getMarkupProvider();
    if (provider == null)
    {
      provider = getParent();
    }

    if (provider.hasAssociatedMarkup())
    {
      markup = provider.getAssociatedMarkup();
    }
    else
    {
      markup = getParent().getMarkup();
    }

    if (markup == null)
    {
      return null;
    }

    markup = markup.find(markupId);

    if (child == null)
    {
      return markup;
    }

    return markup.find(child.getId());
  }
View Full Code Here

   */
  @Override
  public IMarkupFragment getMarkup(final Component child)
  {
    // Border require an associated markup resource file
    IMarkupFragment markup = getAssociatedMarkup();
    if (markup == null)
    {
      throw new MarkupException("Unable to find associated markup file for Border: " +
        this.toString());
    }

    // Find <wicket:border>
    IMarkupFragment childMarkup = null;
    for (int i = 0; i < markup.size(); i++)
    {
      MarkupElement elem = markup.get(i);
      if (elem instanceof WicketTag)
      {
        WicketTag tag = (WicketTag)elem;
        if (tag.isBorderTag())
        {
          childMarkup = new MarkupFragment(markup, i);
          break;
        }
      }
    }

    // If child == null, return the markup fragment starting with the <wicket:border> tag
    if (child == null)
    {
      return childMarkup;
    }

    // Since we created the body component instance, identifying that we found it is easy.
    if (child == body)
    {
      return body.getMarkup();
    }

    // Find the markup for the child component
    childMarkup = childMarkup.find(child.getId());
    if (childMarkup != null)
    {
      return childMarkup;
    }

View Full Code Here

     * @see org.apache.wicket.Component#getMarkup()
     */
    @Override
    public IMarkupFragment getMarkup()
    {
      IMarkupFragment markup = findByName(getParent().getMarkup(null), BODY);
      setMarkup(markup);
      return markup;
    }
View Full Code Here

     * @see org.apache.wicket.MarkupContainer#getMarkup(org.apache.wicket.Component)
     */
    @Override
    public IMarkupFragment getMarkup(final Component child)
    {
      IMarkupFragment markup = Border.this.getMarkup();
      if (markup == null)
      {
        return null;
      }

      if (child == null)
      {
        return markup;
      }

      return markup.find(child.getId());
    }
View Full Code Here

   * @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 render_()
  {
    // Step 1: 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());
    }

    // Step 2: A markup stream based on the markup should yield the same result.
    // We want to use the new markup stream
    MarkupStream markupStream = new MarkupStream(markup);
    setMarkupStream(markupStream);

    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

   * @param markupStream
   *            The markup stream
   */
  public final void renderComponent()
  {
    final IMarkupFragment markup = getMarkup();
    if (markup == null)
    {
      throw new MarkupException("Markup not found. Component: " + toString());
    }

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.