Example usage for org.apache.wicket.markup ComponentTag toString

List of usage examples for org.apache.wicket.markup ComponentTag toString

Introduction

In this page you can find the example usage for org.apache.wicket.markup ComponentTag toString.

Prototype

@Override
public final String toString() 

Source Link

Document

Converts this object to a string representation.

Usage

From source file:com.servoy.j2db.server.headlessclient.dataui.SortableCellViewHeaders.java

License:Open Source License

/**
 * Renders the next element of markup in the given markup stream.
 * /*from   www  .  j ava 2s.  c o m*/
 * @param markupStream 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 && orderedHeaders.get(renderColumnIdx) != null) {
            if (component instanceof SortableCellViewHeader) {
                int currentIdx = markupStream.getCurrentIndex();
                renderHeader(renderColumnIdx, markupStream);
                renderColumnIdx++;
                markupStream.setCurrentIndex(currentIdx);
                markupStream.skipComponent();
            }
        } else {
            // 2rd try: Components like Border and Panel might implement
            // the ComponentResolver interface as well.
            MarkupContainer container = this;
            while (container != null) {
                if (container instanceof SortableCellViewHeaders) {
                    // we should created the corect header, use the id from the orderedHeaders
                    String headerId = orderedHeaderIds.get(renderColumnIdx);
                    renderColumnIdx++;
                    if (resolve(markupStream, tag, headerId)) {
                        return;
                    }

                }

                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>"); //$NON-NLS-1$ //$NON-NLS-2$
                } else {
                    markupStream.throwMarkupException("Failed to handle: " + tag.toString()); //$NON-NLS-1$
                }
            }

            // No one was able to handle the component id
            markupStream.throwMarkupException("Unable to find component with id '" + id + "' in " + this //$NON-NLS-1$//$NON-NLS-2$
                    + ". This means that you declared wicket:id=" + //$NON-NLS-1$
                    id + " in your markup, but that you either did not add the " //$NON-NLS-1$
                    + "component to your page at all, or that the hierarchy does not match."); //$NON-NLS-1$
        }
    } else {
        getResponse().write(element.toCharSequence());
        markupStream.next();
    }
}

From source file:jp.javelindev.wicket.MyMarkupFilter.java

License:Apache License

@Override
protected MarkupElement onComponentTag(ComponentTag tag) throws ParseException {
    String namespace = markup.getWicketNamespace();
    final String wicketIdValue = tag.getAttributes().getString(namespace + ":id");

    //wicket??????wicket:id?????????wicket:id???
    if (!namespace.equalsIgnoreCase(tag.getNamespace()) && Strings.isEmpty(wicketIdValue)) {
        tag.put("wicket:id", "dummy" + count++);
    }/*from   w w w.j  a  va2 s .  c  o m*/
    LOGGER.info(tag.toString());

    return tag;
}

From source file:org.artifactory.common.wicket.component.links.BaseTitledLink.java

License:Open Source License

protected final void replaceBody(MarkupStream markupStream, ComponentTag openTag, String html) {
    replaceComponentTagBody(markupStream, openTag, html);

    if (!wasOpenCloseTag) {
        markupStream.skipRawMarkup();//from  w  ww.j av a  2s  .  co  m
        if (!markupStream.get().closes(openTag)) {
            throw new MarkupException(
                    "close tag not found for tag: " + openTag.toString() + ". Component: " + toString());
        }
    }
}