コード例 #1
0
 public IMarkupFragment getMarkup() {
   IMarkupFragment enclosureMarkup = null;
   if (this.enclosureMarkupAsString == null) {
     final IMarkupFragment markup = super.getMarkup();
     if (markup != null && markup != Markup.NO_MARKUP) {
       enclosureMarkup = markup;
       this.enclosureMarkupAsString = markup.toString(true);
     }
   } else {
     enclosureMarkup = Markup.of(this.enclosureMarkupAsString);
   }
   return enclosureMarkup;
 }
コード例 #2
0
  /**
   * Gets the header part of the Panel/Border. Returns null if it doesn't have a header tag.
   *
   * @param container
   * @param id
   * @param markup
   * @return the header part for this panel/border or null if it doesn't have a wicket:head tag.
   */
  private HeaderPartContainer getHeaderPart(
      final WebMarkupContainer container, final String id, final IMarkupFragment markup) {
    // Create a HtmlHeaderContainer for the header tag found
    final MarkupElement element = markup.get(0);
    if (element instanceof WicketTag) {
      final WicketTag wTag = (WicketTag) element;
      if ((wTag.isHeadTag() == true) && (wTag.getNamespace() != null)) {
        // Create the header container and associate the markup with it
        return new HeaderPartContainer(id, container, markup);
      }
    }

    throw new WicketRuntimeException(
        "Programming error: expected a WicketTag: " + markup.toString());
  }
コード例 #3
0
  /**
   * Search for the child's markup in the associated markup file.
   *
   * @param parent The container expected to contain the markup for child
   * @param child The child component to find the markup for
   * @return The markup associated with the child
   */
  @Override
  public IMarkupFragment getMarkup(final MarkupContainer parent, final Component child) {
    Args.notNull(tagName, "tagName");

    IMarkupFragment associatedMarkup = parent.getAssociatedMarkup();
    if (associatedMarkup == null) {
      throw new MarkupNotFoundException(
          "Failed to find markup file associated. "
              + Classes.simpleName(parent.getClass())
              + ": "
              + parent.toString());
    }

    // Find <wicket:panel>
    IMarkupFragment markup = MarkupUtil.findStartTag(associatedMarkup, tagName);
    if (markup == null) {
      throw new MarkupNotFoundException(
          "Expected to find <wicket:"
              + tagName
              + "> in associated markup file. Markup: "
              + associatedMarkup.toString());
    }

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

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

    associatedMarkup = searchMarkupInTransparentResolvers(parent, markup, child);
    if (associatedMarkup != null) {
      return associatedMarkup;
    }

    return findMarkupInAssociatedFileHeader(parent, child);
  }