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

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

Introduction

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

Prototype

public ComponentTag(final String name, final XmlTag.TagType type) 

Source Link

Document

Automatically create a XmlTag, assign the name and the type, and construct a ComponentTag based on this XmlTag.

Usage

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

License:Apache License

/**
 * @see IMarkupFilter#nextTag()//from   w w w  .ja  v  a  2 s  .  c  o  m
 */
@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:fiftyfive.wicket.css.IterationCssBehaviorTest.java

License:Apache License

@Test(expected = UnsupportedOperationException.class)
public void test_badComponent() throws Exception {
    Label label = new Label("hello", "world");
    IterationCssBehavior behavior = new IterationCssBehavior("first");
    behavior.onComponentTag(label, new ComponentTag("span", TagType.OPEN));
}

From source file:org.cdlflex.ui.behavior.CssClassNameAppenderTest.java

License:Apache License

@Test
public void append_withVarargs_appendsAllClasses() throws Exception {
    ComponentTag a = new ComponentTag("a", XmlTag.TagType.OPEN);
    CssClassNameAppender.append(a, "foo", "bar", "foo");

    List<String> classes = Arrays.asList(a.getAttribute("class").split(" "));
    assertEquals(2, classes.size());/*from   w  ww  .  j a v  a 2  s. c  o  m*/
    assertTrue("class 'foo' not set", classes.contains("foo"));
    assertTrue("class 'bar' not set", classes.contains("bar"));
}

From source file:org.cdlflex.ui.behavior.CssClassNameAppenderTest.java

License:Apache License

@Test
public void append_withICssClassNameProvider_appendsClassesCorrectly() throws Exception {
    ComponentTag a = new ComponentTag("a", XmlTag.TagType.OPEN);

    CssClassNameAppender.append(a, new CssClassNameProvider());

    List<String> classes = Arrays.asList(a.getAttribute("class").split(" "));
    assertEquals(2, classes.size());//from  w  ww  . ja  v  a 2 s .  com
    assertTrue("class 'foo' not set", classes.contains("foo"));
    assertTrue("class 'bar' not set", classes.contains("bar"));
}

From source file:org.cdlflex.ui.behavior.CssClassNameAppenderTest.java

License:Apache License

@SuppressWarnings("unchecked")
@Test/*from  www  . java 2  s  . c o m*/
public void append_withICssClassNameProviderModel_appendsClassesCorrectly() throws Exception {
    ComponentTag a = new ComponentTag("a", XmlTag.TagType.OPEN);

    Model<CssClassNameProvider> model = new Model<>(new CssClassNameProvider());
    CssClassNameAppender.append(a, model);

    List<String> classes = Arrays.asList(a.getAttribute("class").split(" "));
    assertEquals(2, classes.size());
    assertTrue("class 'foo' not set", classes.contains("foo"));
    assertTrue("class 'bar' not set", classes.contains("bar"));
}

From source file:org.hippoecm.frontend.dialog.ButtonWrapper.java

License:Apache License

public void setEnabled(boolean isset) {
    enabled = isset;/*from   w  w w . j  a v  a  2  s .  c  o m*/
    if (button != null && WebApplicationHelper.isPartOfPage(button)) {
        button.setEnabled(isset);
        if (ajax) {
            AjaxRequestTarget target = RequestCycle.get().find(AjaxRequestTarget.class);
            if (target != null) {
                if (!isset) {
                    renderAttribute(target, "disabled", "disabled");
                } else {
                    target.appendJavaScript(
                            "Wicket.$('" + button.getMarkupId() + "').removeAttribute('disabled')");
                    for (Behavior behavior : button.getBehaviors()) {
                        ComponentTag tag = new ComponentTag("button", XmlTag.TagType.OPEN_CLOSE);
                        behavior.onComponentTag(button, tag);
                        behavior.renderHead(button, target.getHeaderResponse());

                        for (Map.Entry<String, Object> entry : tag.getAttributes().entrySet()) {
                            renderAttribute(target, entry.getKey(), entry.getValue());
                        }
                    }
                }
            }
        }
    }
}

From source file:sf.wicklet.wicketext.markup.impl.WicketWriter.java

License:Apache License

public WicketWriter startComp(final String tag, final String id) {
    return start(new ComponentTag(tag, TagType.OPEN), id, id, new ComponentTag(tag, TagType.CLOSE));
}

From source file:sf.wicklet.wicketext.markup.impl.WicketWriter.java

License:Apache License

public WicketWriter emptyComp(final String tag, final String id) {
    return start(new ComponentTag(tag, TagType.OPEN_CLOSE), id, id, null);
}

From source file:sf.wicklet.wicketext.markup.impl.WicketWriter.java

License:Apache License

/** Create ComponentTag without wicket:id attribute, eg. head, link, ...etc. */
public WicketWriter startAutoComp(final String tag, final String id) {
    final ComponentTag ctag = new ComponentTag(tag, TagType.OPEN);
    ctag.setAutoComponentTag(true);//w w  w  .  j a  v  a  2s.c o m
    return start(ctag, id, id, new ComponentTag(tag, TagType.CLOSE));
}

From source file:sf.wicklet.wicketext.markup.impl.WicketWriter.java

License:Apache License

/** Create open-close auto ComponentTag that has an id attribute but no wicket:id attribute, eg. head, link, ...etc. */
public WicketWriter emptyAutoComp(final String tag, final String id) {
    final ComponentTag ctag = new ComponentTag(tag, TagType.OPEN_CLOSE);
    ctag.setAutoComponentTag(true);/*  w  ww .ja v  a2  s  . c  o m*/
    return start(ctag, id, id, null);
}