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

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

Introduction

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

Prototype

public final boolean isOpenClose() 

Source Link

Usage

From source file:com.evolveum.midpoint.web.component.AjaxIconButton.java

License:Apache License

@Override
protected void onComponentTag(ComponentTag tag) {
    super.onComponentTag(tag);

    if (tag.isOpenClose()) {
        tag.setType(XmlTag.TagType.OPEN);
    }/* w ww .  j  av a  2s. co  m*/
}

From source file:com.lyndir.lhunath.snaplog.webapp.filter.OpenCloseTagExpander.java

License:Apache License

/**
 * @see IMarkupFilter#nextTag()/*from   ww  w.  j a  va 2s .  c  om*/
 */
@Override
public MarkupElement nextTag() throws ParseException {

    if (next != null) {
        MarkupElement tmp = next;
        next = null;
        return tmp;
    }

    ComponentTag tag = nextComponentTag();
    if (tag == null)
        return tag;

    if (tag.isOpenClose()) {
        String name = tag.getName();
        if (tag.getNamespace() != null)
            name = tag.getNamespace() + ':' + tag.getName();

        if (replaceForTags.contains(name.toLowerCase(Locale.ENGLISH))) {
            tag.setType(XmlTag.OPEN);

            next = new ComponentTag(tag.getName(), XmlTag.CLOSE);
            next.setNamespace(tag.getNamespace());
            next.setOpenTag(tag);
        }
    }
    return tag;
}

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

License:Open Source License

private void renderSortableCellViewHeaderTagBody(final MarkupStream markupStream, final ComponentTag openTag) {
    renderColumnIdx = 0;//w ww . j  ava 2  s  . c o  m
    headerMarkupStartIdx = markupStream.getCurrentIndex();
    orderedHeaders = view.getOrderedHeaders();
    orderedHeaderIds = view.getOrderedHeaderIds();

    if ((markupStream != null) && (markupStream.getCurrentIndex() > 0)) {
        // If the original tag has been changed from open-close to open-body-close,
        // than historically renderComponentTagBody gets called, but actually
        // it shouldn't do anything since there is no body for that tag.
        ComponentTag origOpenTag = (ComponentTag) markupStream.get(markupStream.getCurrentIndex() - 1);
        if (origOpenTag.isOpenClose()) {
            return;
        }
    }

    // If the open tag requires a close tag
    boolean render = openTag.requiresCloseTag();
    if (render == false) {
        // Tags like <p> do not require a close tag, but they may have.
        render = !openTag.hasNoCloseTag();
    }

    if (render == true) {
        // Loop through the markup in this container
        while (markupStream.hasMore() && !markupStream.get().closes(openTag)) {
            // Render markup element. Doing so must advance the markup
            // stream
            final int index = markupStream.getCurrentIndex();
            _renderNext(markupStream);
            if (index == markupStream.getCurrentIndex()) {
                markupStream.throwMarkupException(
                        "Markup element at index " + index + " failed to advance the markup stream"); //$NON-NLS-1$ //$NON-NLS-2$
            }
        }
    }
}

From source file:jp.xet.uncommons.wicket.gp.BookmarkableForm.java

License:Apache License

private void renderComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) {
    if ((markupStream != null) && (markupStream.getCurrentIndex() > 0)) {
        ComponentTag origOpenTag = (ComponentTag) markupStream.get(markupStream.getCurrentIndex() - 1);
        if (origOpenTag.isOpenClose()) {
            return;
        }//from   ww  w. j  ava2 s.c  o m
    }
    boolean render = openTag.requiresCloseTag();
    if (render == false) {
        render = !openTag.hasNoCloseTag();
    }
    if (render == true) {
        renderAll(markupStream, openTag);
    }
}

From source file:name.martingeisse.wicket.bootstrap.GlyphiconComponent.java

License:Open Source License

/**
 * Adds the CSS classes "glyphicon" and "glyphicon-?" to the specified
 * tag to render the glyph icon in it.//from  www.ja va 2  s  .co m
 * 
 * Note that the tag should not contain text content -- the word spacing
 * from the glyphicon font looks really ugly on normal text.
 * 
 * @param glyphiconIdentifier the glyph icon identifier
 * @param tag the tag to render the glyph icon to
 */
public static void applyGlyphiconToTag(String glyphiconIdentifier, ComponentTag tag) {
    if (tag.isOpenClose()) {
        tag.setType(TagType.OPEN);
    }
    tag.append("class", "glyphicon glyphicon-" + glyphiconIdentifier, " ");

}

From source file:name.martingeisse.wicket.helpers.Iframe.java

License:Open Source License

@Override
protected void onComponentTag(final ComponentTag tag) {
    super.onComponentTag(tag);
    if (tag.isOpenClose()) {
        tag.setType(TagType.OPEN);//from   w w  w  . j  a  v a 2s . c  om
    }
    final Object modelObject = getDefaultModelObject();
    if (modelObject instanceof IResource) {
        tag.put("src", urlFor(IResourceListener.INTERFACE, contentParameters));
    } else if (modelObject instanceof ResourceReference) {
        final ResourceReference resourceReference = (ResourceReference) modelObject;
        if (resourceReference.canBeRegistered() && Application.exists()) {
            Application.get().getResourceReferenceRegistry().registerResourceReference(resourceReference);
        }
        tag.put("src", RequestCycle.get().urlFor(resourceReference, contentParameters));
    } else if (modelObject instanceof IPageProvider) {
        setSrcAttribute(tag, (IPageProvider) modelObject);
    } else if (modelObject instanceof IRequestablePage) {
        setSrcAttribute(tag, new PageProvider((IRequestablePage) modelObject));
    } else if (modelObject instanceof Class<?>) {
        final Class<?> c = (Class<?>) modelObject;
        if (Page.class.isAssignableFrom(c)) {
            setSrcAttribute(tag, new PageProvider(c.asSubclass(Page.class)));
        } else {
            throw new RuntimeException(
                    "cannot handle iframe model object: Class<" + c.getCanonicalName() + ">");
        }
    } else {
        throw new RuntimeException("cannot handle iframe model object: " + modelObject);
    }
}

From source file:net.dontdrinkandroot.wicket.component.basic.ToStringLabel.java

License:Apache License

/**
 * {@inheritDoc}/*from  w  w  w.j  av  a2s . c om*/
 */
@Override
protected void onComponentTag(ComponentTag tag) {

    super.onComponentTag(tag);

    if (tag.isOpenClose()) {
        // always transform the tag to <span></span> so even labels defined as <span/> render
        tag.setType(TagType.OPEN);
    }
}

From source file:org.apache.openmeetings.web.app.MessageTagHandler.java

License:Apache License

public Component resolve(final MarkupContainer container, final MarkupStream markupStream,
        final ComponentTag tag) {
    // localize any raw markup that has wicket:message attrs
    if ((tag != null) && (tag.getId().startsWith(getWicketMessageIdPrefix()))) {
        Component wc;//from w w w.j  a  v a  2  s .  co  m
        int autoIndex = container.getPage().getAutoIndex();
        String id = getWicketMessageIdPrefix() + autoIndex;

        if (tag.isOpenClose()) {
            wc = new WebComponent(id);
        } else {
            wc = new TransparentWebMarkupContainer(id);
        }

        return wc;
    }
    return null;
}

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

License:Open Source License

@Override
protected void onComponentTag(ComponentTag tag) {
    if (tag.isOpenClose()) {
        wasOpenCloseTag = true;//w  w  w .  ja  v a2s  .  c  o m
        tag.setType(XmlTag.TagType.OPEN);
    }

    super.onComponentTag(tag);

    tag.put("class", getCssClass(tag));
    if ("input".equalsIgnoreCase(tag.getName())) {
        tag.put("value", getTitle());
    }

    if (isEnabled()) {
        // is a <a> or other tag
        if ("a".equalsIgnoreCase(tag.getName())) {
            tag.put("href", Strings.replaceAll(getURL(), "&", "&amp;"));
        }
    } else {
        disableLink(tag);
    }
}

From source file:org.dcm4chee.web.war.common.SelectAllLink.java

License:LGPL

@Override
protected void onComponentTag(final ComponentTag tag) {
    if (selectImg != null && tag.isOpenClose()) {
        tag.setType(XmlTag.OPEN);/*ww  w.j a  va 2s.  co  m*/
    }
    super.onComponentTag(tag);
}