Example usage for org.apache.wicket Component getId

List of usage examples for org.apache.wicket Component getId

Introduction

In this page you can find the example usage for org.apache.wicket Component getId.

Prototype

@Override
public String getId() 

Source Link

Document

Gets the id of this component.

Usage

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

License:Open Source License

@Override
public String getInputName() {
    // TODO: This is a copy & paste from the FormComponent class.
    String id = getId();/*  w w w .  j  av  a  2 s .  com*/
    final PrependingStringBuffer inputName = new PrependingStringBuffer(id.length());
    Component c = this;
    while (true) {
        inputName.prepend(id);
        c = c.getParent();
        if (c == null || (c instanceof Form && ((Form) c).isRootForm()) || c instanceof Page) {
            break;
        }
        inputName.prepend(Component.PATH_SEPARATOR);
        id = c.getId();
    }

    // having input name "submit" causes problems with javascript, so we
    // create a unique string to replace it by prepending a path separator
    if ("submit".equals(inputName.toString())) {
        inputName.prepend(Component.PATH_SEPARATOR);
    }
    return inputName.toString();
}

From source file:org.brixcms.markup.MarkupHelper.java

License:Apache License

/**
 * Returns existing tag components on page.
 *
 * @return/*w  ww.  j  a  v a2s .  c  o  m*/
 */
private Set<String> getExistingComponents() {
    Set<String> result = new HashSet<String>();
    Iterator<? extends Component> i = ((MarkupContainer) component).iterator();
    while (i.hasNext()) {
        Component c = i.next();
        if (c.getId().startsWith(COMPONENT_PREFIX)) {
            result.add(c.getId());
        }
    }
    return result;
}

From source file:org.cast.cwm.test.CwmWicketTester.java

License:Open Source License

public void assertAttribute(String message, String expected, Component component, String attribute) {
    String value = getTagByWicketId(component.getId()).getAttribute(attribute);
    assertEquals(String.format("%s: expected \"%s\", got \"%s\"", message, expected, value), expected, value);
}

From source file:org.cast.cwm.test.CwmWicketTester.java

License:Open Source License

public void assertNotAttribute(String message, String expected, Component component, String attribute) {
    assertFalse(message, getTagByWicketId(component.getId()).getAttributeIs(attribute, expected));
}

From source file:org.cdlflex.ui.AbstractWicketTest.java

License:Apache License

public TagTester createTag(String html, Component component) {
    return TagTester.createTagByAttribute(html, "wicket:id", component.getId());
}

From source file:org.cdlflex.ui.AbstractWicketTest.java

License:Apache License

public TagTester renderAndCreateTag(Component component) {
    CharSequence markup = ComponentRenderer.renderComponent(component);
    return TagTester.createTagByAttribute(markup.toString(), "wicket:id", component.getId());
}

From source file:org.cipango.ims.hss.web.gba.NafGroupBrowserPage.java

License:Apache License

@SuppressWarnings("unchecked")
public NafGroupBrowserPage(PageParameters pageParameters) {

    IDataProvider<NafGroup> provider = new AbstractListDataProvider<NafGroup>() {

        @Override//from  w w w  .j  a  v  a2s .c  om
        public List<NafGroup> load() {
            return _dao.getAllGroups();
        }

        public IModel<NafGroup> model(NafGroup nafGroup) {
            return new CompoundPropertyModel<NafGroup>(new DaoDetachableModel(nafGroup)) {
                @Override
                protected String propertyExpression(Component component) {
                    if (component.getParent() instanceof EditableLabel)
                        return component.getParent().getId();
                    return component.getId();
                }
            };
        }

    };

    WebMarkupContainer container = new WebMarkupContainer("browser");
    container.setOutputMarkupId(true);
    add(container);

    container.add(new DataView<NafGroup>("nafGroup", provider, getItemByPage()) {

        @Override
        protected void populateItem(final Item<NafGroup> item) {
            NafGroup nafGroup = item.getModelObject();
            Form form = new Form("form", item.getModel());
            item.add(form);
            form.add(new EditableLabel("name"));
            form.add(new AjaxFallbackButton("apply", form) {

                @Override
                protected void doSubmit(AjaxRequestTarget target, Form<?> form) throws Exception {
                    NafGroup nafGroup = (NafGroup) form.getDefaultModelObject();
                    _dao.save(nafGroup);
                    EditableLabel name = (EditableLabel) form.get("name");
                    name.setEditable(false);
                    setVisible(false);
                    if (target != null)
                        target.addComponent(item);

                }

            }.setVisible(false));

            item.add(new Label("nbUss", String.valueOf(nafGroup.getUssSet().size())));
            item.add(new AjaxFallbackLink("editLink") {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    EditableLabel name = (EditableLabel) item.get("form:name");
                    item.get("form:apply").setVisible(true);
                    name.setEditable(true);
                    if (target != null)
                        target.addComponent(item);
                }

            });

            item.add(new AjaxFallbackLink("deleteLink") {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    NafGroup nafGroup = (NafGroup) getParent().getDefaultModelObject();
                    _dao.delete(nafGroup);
                    if (target != null)
                        target.addComponent(getPage().get("browser"));
                }

            });
            item.setOutputMarkupId(true);
            item.add(new OddEvenAttrModifier(item.getIndex()));
        }

    });

    Form form = new Form("form", new CompoundPropertyModel(new DaoDetachableModel(null)));
    add(form);
    form.add(new RequiredTextField("name", String.class));
    form.add(new AjaxFallbackButton("submit", form) {

        @Override
        protected void doSubmit(AjaxRequestTarget target, Form<?> form) throws Exception {
            try {
                _dao.save((NafGroup) form.getDefaultModelObject());
                if (target != null) {
                    target.addComponent(getPage().get("browser"));
                }
            } catch (Exception e) {
                __log.debug("Failed to apply edit", e);
                getSession().error(getString("nafGroup.error.duplicate", getForm().getModel()));
            }
        }

    });
    setContextMenu(new ServicesContextPanel());
}

From source file:org.dcm4chee.web.common.behaviours.TooltipBehaviour.java

License:LGPL

String getResourceKey(Component c) {
    if (generateComponentTreePrefix)
        prefix = generateComponentTreePrefix(c);
    StringBuilder sb = new StringBuilder();
    if (prefix != null)
        sb.append(prefix);/*from   w ww  .j a va  2  s  .c  o m*/
    sb.append(id == null ? c.getId() : id);
    sb.append(this.showTooltipModel == null ? "" : "." + (this.showTooltipModel.getObject() ? "hide" : "show"));
    sb.append(POSTFIX);
    return sb.toString();
}

From source file:org.dcm4chee.web.common.behaviours.TooltipBehaviour.java

License:LGPL

private String generateComponentTreePrefix(Component c) {
    generateComponentTreePrefix = false;
    StringBuilder sb = new StringBuilder("");
    Component parent = c.getParent();
    while ((parent != null) && !parent.equals("") && !(parent instanceof BaseForm)) {
        sb.insert(0, ".");
        sb.insert(0, parent.getId());
        parent = parent.getParent();/*  w w w. j  ava  2s.c  om*/
    }
    if ((prefix != null) && (!prefix.equals("")))
        sb.insert(0, prefix);
    return sb.toString();
}

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

License:LGPL

private void addToTarget(final AjaxRequestTarget target) {
    final String excludeId = getComponent().getId();
    IVisitor<Component> visitor = new IVisitor<Component>() {
        public Object component(Component c) {
            if (c instanceof FormComponent<?> && c.getOutputMarkupId() && !c.getId().equals(excludeId)) {
                target.addComponent(c);/*from   ww  w . j  av  a2  s .c o m*/
            }
            return IVisitor.CONTINUE_TRAVERSAL;
        }
    };
    form.visitChildren(visitor);
}