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

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

Introduction

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

Prototype

public final String getName() 

Source Link

Usage

From source file:com.aplombee.RepeaterUtilTest.java

License:Apache License

/**
 * check with testpanel/*  www. j a v a2  s.c  o  m*/
 */

@Test(groups = { "utilTests" })
public void getComponentTag_1() {

    QuickMockApplication app = new QuickMockApplication();
    WicketTester tester = new WicketTester(app);
    final QuickViewParent parent = new QuickViewParent("parent");
    List<Integer> list = new ArrayList<Integer>();
    list.add(100);
    list.add(500);
    IDataProvider<Integer> dataProvider = new ListDataProvider<Integer>(list);
    final QuickGridView<Integer> quickView = new QuickGridView<Integer>("quickview", dataProvider) {
        @Override
        protected void populate(CellItem<Integer> item) {
        }

        @Override
        protected void populateEmptyItem(CellItem<Integer> item) {
        }
    };
    quickView.setColumns(2);
    quickView.setReuseStrategy(new ItemsNavigationStrategy());
    parent.setOutputMarkupId(true);
    parent.add(quickView);

    TestQuickGridViewContainer panel = new TestQuickGridViewContainer("panel") {

        @Override
        public QuickViewParent newParent() {
            return parent;
        }
    };
    tester.startComponentInPage(panel);
    final Item<Integer> item = (Item) quickView.getRow(0);
    ComponentTag actual = RepeaterUtil.get().getComponentTag(item);
    Assert.assertEquals(actual.getName(), "tr");
}

From source file:com.aplombee.RepeaterUtilTest.java

License:Apache License

/**
 * check with testpanel2//from w w w  .  jav a2  s  .  c  o  m
 */

@Test(groups = { "utilTests" })
public void getComponentTag_2() {

    QuickMockApplication app = new QuickMockApplication();
    WicketTester tester = new WicketTester(app);
    final QuickViewParent parent = new QuickViewParent("parent");
    List<Integer> list = new ArrayList<Integer>();
    list.add(100);
    IDataProvider<Integer> dataProvider = new ListDataProvider<Integer>(list);
    final QuickView<Integer> quickView = new QuickView<Integer>("quickview", dataProvider, 2) {
        @Override
        protected void populate(Item<Integer> item) {
        }
    };
    quickView.setReuseStrategy(new ItemsNavigationStrategy());
    parent.setOutputMarkupId(true);
    parent.add(quickView);

    TestQuickViewContainer panel = new TestQuickViewContainer("panel") {
        @Override
        public QuickViewParent newParent() {
            return parent;
        }
    };
    tester.startComponentInPage(panel);
    final Item<Integer> item = (Item) quickView.get(0);
    ComponentTag actual = RepeaterUtil.get().getComponentTag(item);
    Assert.assertEquals(actual.getName(), TestQuickViewContainer.TAG_NAME);
}

From source file:com.conwax.ajax.SimpleAjaxFallbackLink.java

License:Apache License

/**
 * Removes any inline 'onclick' attributes set by
 * Link#onComponentTag(ComponentTag).//w  ww . j  av a2s  .  c  om
 * 
 * @param tag
 *            the component tag
 */
@Override
protected void onComponentTag(ComponentTag tag) {
    super.onComponentTag(tag);

    // Ajax links work with JavaScript Event registration
    tag.remove("onclick");

    String tagName = tag.getName();
    if (isLinkEnabled() && !("a".equalsIgnoreCase(tagName) || "area".equalsIgnoreCase(tagName)
            || "link".equalsIgnoreCase(tagName))) {
        String msg = String.format(
                "%s must be used only with <a>, <area> or <link> markup elements. "
                        + "The fallback functionality doesn't work for other markup elements. "
                        + "Component path: %s, markup element: <%s>.",
                SimpleAjaxFallbackLink.class.getSimpleName(), getClassRelativePath(), tagName);
        findMarkupStream().throwMarkupException(msg);
    }
}

From source file:com.conwax.ajax.SimpleAjaxLink.java

License:Apache License

/**
 * @param tag/*from ww  w.j ava 2  s .co  m*/
 *            the component tag
 */
@Override
protected void onComponentTag(ComponentTag tag) {
    super.onComponentTag(tag);

    if (isLinkEnabled()) {
        // disable any href attr in markup
        if (tag.getName().equalsIgnoreCase("a") || tag.getName().equalsIgnoreCase("link")
                || tag.getName().equalsIgnoreCase("area")) {
            tag.put("href", "#");
        }
    } else {
        disableLink(tag);
    }
}

From source file:com.googlecode.wicket.kendo.ui.widget.menu.form.MenuItemForm.java

License:Apache License

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

    tag.put("onclick", this.getOnClickStatement());

    // KendoUI Menu component uses <li><span class="k-link"> as a parent of the menu items
    // If there is a outer form Wicket will change the tag name to <div>
    // but the browser will render this <div> as a sibling to <span class="k-link"> instead of a child
    // this will break the JavaScript event propagation because the KendoUI click listener is on '.k-link'
    if ("div".equals(tag.getName())) {
        tag.setName("span");
    }/* ww  w  . j  a  v  a2  s.  c  o  m*/
}

From source file:com.googlecode.wicketcontinuouscalendar.wicket15.ContinuousCalendar.java

License:Apache License

/**
 * Handles this calendar's tag. OVERRIDES MUST CALL SUPER.
 * // ww w . j  a v a 2 s . c  o  m
 * @param tag
 *            the component tag
 * @see org.apache.wicket.Component#onComponentTag(ComponentTag)
 */
@Override
protected void onComponentTag(final ComponentTag tag) {
    // Default handling for tag
    super.onComponentTag(tag);

    // Force the tag to be a DIV
    if (!tag.getName().equalsIgnoreCase("div")) {
        throw new WicketRuntimeException("a jQuery-Continuous-Calendar component was set on " + tag.getName()
                + " but it has to be attached to a DIV tag");
    }
}

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

License:Apache License

/**
 * @see IMarkupFilter#nextTag()//from w w w.  ja va 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:com.norconex.commons.wicket.bootstrap.form.BootstrapSelect.java

License:Apache License

@Override
public void onComponentTag(Component component, ComponentTag tag) {
    if (!"select".equalsIgnoreCase(tag.getName())) {
        throw new WicketRuntimeException("BootstrapSelect can only be applied to <select> tags.");
    }//w  ww .  j a  v  a2 s.c om
    super.onComponentTag(component, tag);
}

From source file:com.norconex.commons.wicket.bootstrap.modal.BootstrapModalLauncher.java

License:Apache License

@Override
public void onComponentTag(Component component, ComponentTag tag) {
    if (!"button".equalsIgnoreCase(tag.getName()) && !"a".equalsIgnoreCase(tag.getName())) {
        throw new WicketRuntimeException(
                "BootstrapModalLauncher can only be applied to " + "<button> or <a> tags.");
    }//from  w w  w .j  a  v a  2s . c  om
    super.onComponentTag(component, tag);
}

From source file:com.olegchir.flussonic_userlinks.wicket.IncludeResolver.IncludeResolver.java

License:Apache License

/**
 * Handles resolving the wicket:include tag. If a filename is specified this
 * file will be looked up. If a key is specified it's value is looked up
 * using the resource mechanism. The looked up value will then be used as
 * filename./* ww w . j  a  v a  2 s.c o  m*/
 *
 */
public Component resolve(MarkupContainer container, MarkupStream markupStream, ComponentTag tag) {

    if ((tag instanceof WicketTag) && tagname.equalsIgnoreCase(tag.getName())) {
        WicketTag wtag = (WicketTag) tag;

        String fileName = StringUtils.trimToNull(wtag.getAttribute("file"));
        String fileKey = StringUtils.trimToNull(wtag.getAttribute("key"));

        if (null != fileKey) {
            if (null != fileName) {
                throw new MarkupException("Wrong format of: you must not use file and key attribtue at once");
            }
            fileName = StringUtils.trimToNull(container.getString(fileKey));
            if (null == fileName) {
                throw new MarkupException("The key inside could not be resolved");
            }

        } else if (null == fileName) {
            throw new MarkupException("Wrong format of: specify the file or key attribute");
        }

        final String id = "_" + tagname + "_" + container.getPage().getAutoIndex();
        IncludeContainer ic = new IncludeContainer(id, fileName, fileKey, markupStream);
        ic.setRenderBodyOnly(container.getApplication().getMarkupSettings().getStripWicketTags());
        //            container.autoAdd(ic, markupStream);

        return ic;

    }
    return null;
}