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:au.org.theark.core.web.component.tabbedPanel.DynamicTabbedPanel.java

License:Open Source License

/**
 * sets the selected tab/*  w w w. j  av a2 s . c o m*/
 * 
 * @param index
 *           index of the tab to select
 * @return this for chaining
 */
public DynamicTabbedPanel setSelectedTab(final int index) {
    if ((index < 0) || ((index >= tabModel.getObject().size()) && (index > 0))) {
        throw new IndexOutOfBoundsException();
    }

    setDefaultModelObject(index);

    final Component component;

    if ((tabModel.getObject().size() == 0) || !isTabVisible(index)) {
        // no tabs or the currently selected tab is not visible
        component = new EmptyPanel(TAB_PANEL_ID);
    } else {
        // show panel from selected tab
        ITab tab = tabModel.getObject().get(index);
        component = tab.getPanel(TAB_PANEL_ID);
        if (component == null) {
            throw new WicketRuntimeException("ITab.getPanel() returned null. TabbedPanel [" + getPath()
                    + "] ITab index [" + index + "]");
        }
    }

    if (!component.getId().equals(TAB_PANEL_ID)) {
        throw new WicketRuntimeException("ITab.getPanel() returned a panel with invalid id ["
                + component.getId()
                + "]. You must always return a panel with id equal to the provided panelId parameter. TabbedPanel ["
                + getPath() + "] ITab index [" + index + "]");
    }

    addOrReplace(component);

    return this;
}

From source file:au.org.theark.core.web.form.AbstractWizardStepPanel.java

License:Open Source License

protected void setContent(AjaxRequestTarget target, Component content) {
    if (!content.getId().equals(getContentId()))
        throw new IllegalArgumentException(
                "Expected content id is " + getContentId() + " but " + content.getId() + " was found.");

    Component current = get(getContentId());
    if (current == null) {
        add(content);/* w w  w  .j a v  a 2s.  com*/
    } else {
        current.replaceWith(content);
        if (target != null) {
            target.add(get(getContentId()));
        }
    }

}

From source file:au.org.theark.core.web.form.HistoryAjaxBehavior.java

License:Open Source License

/**
 * Registers a new entry in the history if this request is not triggered by back/forward buttons
 * //from   ww w  .  j  ava 2  s .  com
 * @param target
 *           the current request target
 * @param component
 *           the component which triggered this Ajax request
 */
public void registerAjaxEvent(final AjaxRequestTarget target, final Component component) {
    if (RequestCycle.get().getRequest().getRequestParameters()
            .getParameterValue(HistoryAjaxBehavior.HISTORY_ITEM_PARAM).isNull()) {
        target.appendJavaScript("HistoryManager.addHistoryEntry('" + component.getId() + "');");
    }
}

From source file:com.doculibre.constellio.wicket.components.modal.NonAjaxModalWindow.java

License:Apache License

/**
 * @see org.apache.wicket.MarkupContainer#remove(org.apache.wicket.Component)
 *//*from   w w  w . j a v  a2 s  .  c om*/
public void remove(Component component) {
    super.remove(component);
    if (component.getId().equals(getContentId())) {
        add(empty = new WebMarkupContainer(getContentId()));
    }
}

From source file:com.doculibre.constellio.wicket.components.modal.NonAjaxModalWindow.java

License:Apache License

/**
 * Sets the content of the modal window.
 * /*from w  ww.  ja v a  2  s  . c o  m*/
 * @param component
 */
public void setContent(Component component) {
    if (component.getId().equals(getContentId()) == false) {
        throw new WicketRuntimeException("Modal window content id is wrong.");
    }
    component.setOutputMarkupPlaceholderTag(true);
    component.setVisible(false);
    replace(component);
    shown = false;
    pageCreator = null;
}

From source file:com.ecom.web.components.gmap.api.GInfoWindowTab.java

License:Apache License

/**
 * Construct.
 * 
 * @param content
 */
public GInfoWindowTab(Component content) {
    this(content.getId(), content);
}

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

License:Apache License

private void setCurrentTab(int index) {
    if (this.currentTab == index) {
        // already current
        return;/*from  ww  w .j a v  a2  s  . co m*/
    }
    this.currentTab = index;

    final Component component;

    if (currentTab == -1 || (tabs.getObject().size() == 0) || !getVisiblityCache().isVisible(currentTab)) {
        // no tabs or the current tab is not visible
        component = newPanel();
    } else {
        // show panel from selected tab
        T tab = tabs.getObject().get(currentTab);
        component = tab.getPanel(TAB_PANEL_ID);
        if (component == null) {
            throw new WicketRuntimeException("ITab.getPanel() returned null. TabbedPanel [" + getPath()
                    + "] ITab index [" + currentTab + "]");
        }
    }

    if (!component.getId().equals(TAB_PANEL_ID)) {
        throw new WicketRuntimeException("ITab.getPanel() returned a panel with invalid id ["
                + component.getId()
                + "]. You must always return a panel with id equal to the provided panelId parameter. TabbedPanel ["
                + getPath() + "] ITab index [" + currentTab + "]");
    }

    addOrReplace(component);
}

From source file:com.evolveum.midpoint.web.util.SchrodingerComponentInitListener.java

License:Apache License

private void handleId(Component component) {
    writeDataAttribute(component, ATTR_ID, component.getId());
}

From source file:com.evolveum.midpoint.web.util.SchrodingerComponentInitListener.java

License:Apache License

private void writeDataAttribute(Component component, String key, String value) {
    if (!component.getRenderBodyOnly()) {
        component.add(AttributeModifier.append(ATTR_DATA_PREFIX + key, value));
        return;/* w  w w.  j ava  2  s . co  m*/
    }

    if ("title".equals(component.getId()) && component.getParent() instanceof Page) {
        // we don't want to alter <title> element
        return;
    }

    component.add(new Behavior() {

        @Override
        public void afterRender(Component component) {
            Response resp = component.getResponse();
            resp.write("<schrodinger " + ATTR_DATA_PREFIX + key + "=\"" + value + "\"></schrodinger>");
        }
    });
}

From source file:com.francetelecom.clara.cloud.presentation.designer.services.LogicalServiceBasePanel.java

License:Apache License

@Override
protected void onInitialize() {
    serviceForm.visitChildren(FormComponent.class, new IVisitor<Component, Void>() {
        @Override//from  w  ww.  j a v a2s.  com
        public void component(Component component, IVisit<Void> visit) {
            component.add(new FieldFeedbackDecorator());

            if (!component.equals(addUpdateButton) && !component.equals(cancelCloseButton)) {

                boolean serviceParameterEnable = true;

                if (parentPage instanceof DesignerPage) {
                    serviceParameterEnable = ((DesignerPage) parentPage)
                            .isServiceParameterEnable(serviceForm.getModelObject(), component.getId());
                }

                if (!serviceParameterEnable) {
                    component.setEnabled(false);
                }

            }

            // To disable all field except close button in readOnly mode
            if (readOnly) {
                if (!component.equals(cancelCloseButton)) {
                    component.setEnabled(false);
                }
            }
            // overridable components are re-enabled in subclasses, validation button here
            if (configOverride) {
                addUpdateButton.setEnabled(true);
            }

            visit.dontGoDeeper();
        }

    });

    super.onInitialize();

}