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.geoserver.web.wicket.GeoServerTablePanel.java

License:Open Source License

protected void buildRowListView(final GeoServerDataProvider<T> dataProvider, Item item,
        final IModel itemModel) {
    // create one component per viewable property
    ListView items = new ListView("itemProperties", dataProvider.getVisibleProperties()) {

        @Override//from ww w  .  java2 s  .  co  m
        protected void populateItem(ListItem item) {
            Property<T> property = (Property<T>) item.getModelObject();

            Component component = getComponentForProperty("component", itemModel, property);

            if (component == null) {
                // show a plain label if the the subclass did not create any component
                component = new Label("component", property.getModel(itemModel));
            } else if (!"component".equals(component.getId())) {
                // add some checks for the id, the error message
                // that wicket returns in case of mismatch is not
                // that helpful
                throw new IllegalArgumentException("getComponentForProperty asked " + "to build a component "
                        + "with id = 'component' " + "for property '" + property.getName() + "', but got '"
                        + component.getId() + "' instead");
            }
            item.add(component);
            onPopulateItem(property, item);
        }
    };
    items.setReuseItems(true);
    item.add(items);
}

From source file:org.geoserver.web.wicket.ReorderableTablePanel.java

License:Open Source License

protected void buildRowListView(final GeoServerDataProvider<T> dataProvider, Item item,
        final IModel itemModel) {
    // create one component per viewable property
    ListView items = new ListView("itemProperties", dataProvider.getVisibleProperties()) {

        @Override//w  ww . ja  v  a  2s  . c  o m
        protected void populateItem(ListItem item) {
            Property<T> property = (Property<T>) item.getModelObject();

            Component component = null;
            if (property == POSITION) {
                ParamResourceModel upTitle = new ParamResourceModel("moveToTop", this);
                ParamResourceModel downTitle = new ParamResourceModel("moveToBottom", this);
                component = new UpDownPanel<T>("component", (T) itemModel.getObject(), dataProvider.getItems(),
                        ReorderableTablePanel.this, upTitle, downTitle);

            } else if (property == RENDERING_ORDER) {
                component = new Label("component", new Model());
            } else {
                component = getComponentForProperty("component", itemModel, property);
            }

            if (component == null) {
                // show a plain label if the the subclass did not create any component
                component = new Label("component", property.getModel(itemModel));
            } else if (!"component".equals(component.getId())) {
                // add some checks for the id, the error message
                // that wicket returns in case of mismatch is not
                // that helpful
                throw new IllegalArgumentException("getComponentForProperty asked " + "to build a component "
                        + "with id = 'component' " + "for property '" + property.getName() + "', but got '"
                        + component.getId() + "' instead");
            }
            item.add(component);
            onPopulateItem(property, item);
        }
    };
    items.setReuseItems(true);
    item.add(items);

    this.setOutputMarkupId(true);
}

From source file:org.geoserver.web.wicket.WicketHierarchyPrinter.java

License:Open Source License

/**
 * Prints a single component/*from   ww  w.  j a  v  a  2  s  .  c o  m*/
 */
private void printComponent(Component c, int level) {
    if (c instanceof Page)
        out.print(tab(level) + "PAGE_ROOT");
    else
        out.print(tab(level) + c.getId());

    if (pathDumpEnabled) {
        out.print(" " + c.getPageRelativePath());
    }

    if (classDumpEnabled) {
        String className;
        if (c.getClass().isAnonymousClass()) {
            className = c.getClass().getSuperclass().getName();
        } else {
            className = c.getClass().getName();
        }

        out.print("(" + className + ")");
    }

    if (valueDumpEnabled) {
        try {
            String value = NEWLINE.matcher(c.getDefaultModelObjectAsString()).replaceAll("\\\\n");
            out.print(" '" + value + "'");
        } catch (Exception e) {
            out.print(" 'ERROR_RETRIEVING_MODEL " + e.getMessage() + "'");
        }
    }

    out.println();
}

From source file:org.geoserver.wicket.test.TestHomePage.java

License:Open Source License

/**
 * Constructor that is invoked when page is invoked without a session.
 * /* ww w. j  a  v  a2 s  .  com*/
 * @param parameters
 *            Page parameters
 */
public TestHomePage() {
    Component component = componentFactory.createComponent("component");
    if (component instanceof Page)
        setResponsePage((Page) component);
    else {
        if (!"component".equals(component.getId()))
            throw new IllegalArgumentException("Component factory was asked to produce a componet with "
                    + "id 'component' but returned one with id '" + component.getId());
        add(component);
    }

}

From source file:org.geoserver.wms.eo.web.EoLayerGroupEditPage.java

License:Open Source License

public EoLayerGroupEditPage(PageParameters parameters) {
    String groupName = parameters.getString(GROUP);
    String wsName = parameters.getString(WORKSPACE);

    LayerGroupInfo lg = wsName != null ? getCatalog().getLayerGroupByName(wsName, groupName)
            : getCatalog().getLayerGroupByName(groupName);

    if (lg == null) {
        error(new ParamResourceModel("LayerGroupEditPage.notFound", this, groupName).getString());
        doReturn(LayerGroupPage.class);
        return;/*  w ww  . ja  v  a2 s  .c o  m*/
    }

    initUI(lg);

    if (!isAuthenticatedAsAdmin()) {
        Form f = (Form) get("form");

        //global layer groups only editable by full admin
        if (lg.getWorkspace() == null) {
            //disable all form components but cancel
            f.visitChildren(new IVisitor<Component>() {
                @Override
                public Object component(Component c) {
                    if (!(c instanceof AbstractLink && "cancel".equals(c.getId()))) {
                        c.setEnabled(false);
                    }
                    return CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER;
                }
            });
            f.get("save").setVisible(false);

            info(new StringResourceModel("globalLayerGroupReadOnly", this, null).getString());
        }

        //always disable the workspace toggle
        f.get("workspace").setEnabled(false);
    }
}

From source file:org.hippoecm.addon.workflow.MenuButton.java

License:Apache License

MenuButton(String id, String name, final MenuHierarchy menu, final List<MenuDescription> descriptions,
        IPluginConfig config) {/*  w w w.ja va  2 s. c o  m*/
    super(id);
    setOutputMarkupId(true);
    add(content = new MenuList("item", menu, config));
    content.setOutputMarkupId(true);
    content.setVisible(false);

    AbstractLink link;
    add(link = new AjaxLink("link") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            attributes.getAjaxCallListeners().add(new EventStoppingDecorator());
        }

        void updateContent() {
            if (descriptions != null) {
                menu.clear();
                MenuVisitor visitor = new MenuVisitor(menu, "list");
                for (MenuDescription description : descriptions) {
                    MarkupContainer descriptionContent = description.getContent();
                    if (descriptionContent != null) {
                        descriptionContent.visitChildren(Panel.class, visitor);
                    }
                }
                menu.flatten();
                content.update();
            }
        }

        @Override
        public void onClick(AjaxRequestTarget target) {
            content.setVisible(!content.isVisible());
            target.add(MenuButton.this);
            if (content.isVisible()) {
                updateContent();
                IContextMenuManager manager = getContextMenuManager();
                manager.showContextMenu(MenuButton.this);
            }
        }
    });

    link.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {
        @Override
        public String getObject() {
            return content.isVisible() ? "menu-item-active" : "menu-item-inactive";
        }
    }, " "));

    Component label = null;
    if (descriptions != null) {
        label = descriptions.get(0).getLabel();
    }
    if (label == null) {
        link.add(new Label("label", new ResourceBundleModel("hippo:workflows", name, name)));
    } else {
        if (!"label".equals(label.getId())) {
            throw new WicketRuntimeException(
                    "Menu label component doesn't have correct id.  Should be 'label', but was '"
                            + label.getId() + "'");
        }
        link.add(label);
    }

    link.add(HippoIcon.fromSprite("icon", Icon.CHEVRON_DOWN, IconSize.S));
}

From source file:org.obiba.onyx.marble.core.wicket.consent.ElectronicConsentPanel.java

License:Open Source License

@Override
protected void onBeforeRender() {
    Boolean consentIsAccepted = activeConsentService.getConsent().isAccepted();
    Boolean consentIsValid = activeConsentService.validateElectronicConsent();
    Boolean consentIsSubmitted = activeConsentService.isConsentFormSubmitted();
    Component finishButton = form.getFinishLink();

    // If consent form not submitted yet, display a new blank form in the IFrame.
    if (!consentIsSubmitted) {
        addOrReplace(new InlineFrame("pdfSubmitFrame", new ElectronicConsentPage(finishButton)));

        // If consent form is submitted and valid, display confirmation page in the IFrame.
    } else if (!consentIsAccepted || (consentIsAccepted && consentIsValid)) {
        addOrReplace(/*  ww w.ja  va 2 s  .c  o  m*/
                new InlineFrame("pdfSubmitFrame", new ElectronicConsentSubmittedPage(finishButton.getId())));

        // If submitted but invalid, display current form in the IFrame + error message.
    } else if (consentIsAccepted && !consentIsValid) {
        addOrReplace(new InlineFrame("pdfSubmitFrame", new ElectronicConsentPage(finishButton)));
        error(getString("InvalidConsentForm"));
    }
    super.onBeforeRender();
}

From source file:org.obiba.onyx.wicket.behavior.ajaxbackbutton.HistoryAjaxBehavior.java

License:Open Source License

/**
 * Registers a new entry in the history if this request is not triggered by back/forward buttons
 * /* w w  w. j  av a 2s. c  o  m*/
 * @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().getParameter(HistoryAjaxBehavior.HISTORY_ITEM_PARAM) == null) {
        target.appendJavascript("HistoryManager.addHistoryEntry('" + component.getId() + "');");
    }
}

From source file:org.obiba.onyx.wicket.reusable.Dialog.java

License:Open Source License

/**
 * Sets the content of the dialog box./*from  ww w  . j  a  v  a 2 s .  c  o m*/
 * 
 * @param component
 */
@Override
public Dialog setContent(Component component) {
    if (component.getId().equals(getContentId()) == false) {
        throw new WicketRuntimeException("Dialog box content id is wrong.");
    }
    component.setOutputMarkupPlaceholderTag(true);
    component.setVisible(true);
    form.replace(component);
    return this;
}

From source file:org.obiba.onyx.wicket.wizard.WizardStepPanel.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);/*from  w w w. j a va  2  s. co  m*/
    } else {
        current.replaceWith(content);
        if (target != null) {
            target.addComponent(get(getContentId()));
        }
    }

}