Example usage for org.apache.wicket.ajax.markup.html AjaxLink add

List of usage examples for org.apache.wicket.ajax.markup.html AjaxLink add

Introduction

In this page you can find the example usage for org.apache.wicket.ajax.markup.html AjaxLink add.

Prototype

public MarkupContainer add(final Component... children) 

Source Link

Document

Adds the child component(s) to this container.

Usage

From source file:com.evolveum.midpoint.web.component.form.multivalue.MultiValueAutoCompleteTextPanel.java

License:Apache License

private void initButtons(WebMarkupContainer buttonGroup, final ListItem<T> item) {
    AjaxLink add = new AjaxLink(ID_ADD) {

        @Override/*from w w  w  .  j  a  v a  2s.c o  m*/
        public void onClick(AjaxRequestTarget target) {
            addValuePerformed(target);
        }
    };
    add.add(new AttributeAppender("class", getPlusClassModifier(item)));
    buttonGroup.add(add);

    AjaxLink remove = new AjaxLink(ID_REMOVE) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            removeValuePerformed(target, item);
        }
    };
    remove.add(new AttributeAppender("class", getMinusClassModifier()));
    buttonGroup.add(remove);
}

From source file:com.evolveum.midpoint.web.component.form.multivalue.MultiValueDropDownPanel.java

License:Apache License

private void initLayout(final boolean nullValid) {
    WebMarkupContainer placeholderContainer = new WebMarkupContainer(ID_PLACEHOLDER_CONTAINER);
    placeholderContainer.setOutputMarkupPlaceholderTag(true);
    placeholderContainer.setOutputMarkupPlaceholderTag(true);
    placeholderContainer.add(new VisibleEnableBehaviour() {

        @Override/*from  w  w  w  .j  av  a  2  s  .  c o  m*/
        public boolean isVisible() {
            return getModel().getObject().isEmpty();
        }
    });
    add(placeholderContainer);

    AjaxLink placeholderAdd = new AjaxLink(ID_PLACEHOLDER_ADD) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            addValuePerformed(target);
        }
    };
    placeholderAdd.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (buttonsDisabled()) {
                return " " + CSS_DISABLED;
            }

            return "";
        }
    }));
    placeholderAdd.setOutputMarkupId(true);
    placeholderAdd.setOutputMarkupPlaceholderTag(true);
    placeholderContainer.add(placeholderAdd);

    ListView repeater = new ListView<T>(ID_REPEATER, getModel()) {

        @Override
        protected void populateItem(final ListItem<T> item) {

            DropDownChoice choice = new DropDownChoice<>(ID_INPUT, createDropDownItemModel(item.getModel()),
                    createChoiceList(), createRenderer());
            choice.setNullValid(nullValid);
            item.add(choice);

            WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
            item.add(buttonGroup);
            initButtons(buttonGroup, item);
        }
    };
    repeater.setOutputMarkupId(true);
    repeater.setOutputMarkupPlaceholderTag(true);
    repeater.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !getModel().getObject().isEmpty();
        }
    });
    add(repeater);
}

From source file:com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextEditPanel.java

License:Apache License

private void initLayout(final boolean inputEnabled) {
    WebMarkupContainer placeholderContainer = new WebMarkupContainer(ID_PLACEHOLDER_CONTAINER);
    placeholderContainer.setOutputMarkupPlaceholderTag(true);
    placeholderContainer.setOutputMarkupPlaceholderTag(true);
    placeholderContainer.add(new VisibleEnableBehaviour() {

        @Override//from w  w  w.j a  v  a 2  s. c om
        public boolean isVisible() {
            return getModel().getObject().isEmpty();
        }
    });
    add(placeholderContainer);

    AjaxLink placeholderAdd = new AjaxLink(ID_PLACEHOLDER_ADD) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            addValuePerformed(target);
        }
    };
    placeholderAdd.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (buttonsDisabled()) {
                return " " + CSS_DISABLED;
            }

            return "";
        }
    }));
    placeholderAdd.setOutputMarkupId(true);
    placeholderAdd.setOutputMarkupPlaceholderTag(true);
    placeholderContainer.add(placeholderAdd);

    ListView repeater = new ListView<T>(ID_REPEATER, getModel()) {

        @Override
        protected void populateItem(final ListItem<T> item) {
            TextField text = new TextField<>(ID_TEXT, createTextModel(item.getModel()));
            text.add(new AjaxFormComponentUpdatingBehavior("onblur") {

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            });
            text.add(AttributeAppender.replace("placeholder", createEmptyItemPlaceholder()));

            if (!inputEnabled) {
                text.add(new AttributeModifier("disabled", "disabled"));
            }
            item.add(text);

            WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
            item.add(buttonGroup);
            initButtons(buttonGroup, item);
        }
    };
    repeater.setOutputMarkupId(true);
    repeater.setOutputMarkupPlaceholderTag(true);
    repeater.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !getModel().getObject().isEmpty();
        }
    });
    add(repeater);
}

From source file:com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextEditPanel.java

License:Apache License

private void initButtons(WebMarkupContainer buttonGroup, final ListItem<T> item) {
    AjaxSubmitLink edit = new AjaxSubmitLink(ID_EDIT) {

        @Override/*w w  w .  j  a  v  a 2 s  .  c o m*/
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            editPerformed(target, item.getModelObject());
        }
    };
    edit.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (buttonsDisabled()) {
                return " " + CSS_DISABLED;
            }

            return "";
        }
    }));
    buttonGroup.add(edit);

    AjaxLink add = new AjaxLink(ID_ADD) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            addValuePerformed(target);
        }
    };
    add.add(new AttributeAppender("class", getPlusClassModifier(item)));
    buttonGroup.add(add);

    AjaxLink remove = new AjaxLink(ID_REMOVE) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            removeValuePerformed(target, item);
        }
    };
    remove.add(new AttributeAppender("class", getMinusClassModifier()));
    buttonGroup.add(remove);
}

From source file:com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextFormGroup.java

License:Apache License

private void initButtons(WebMarkupContainer buttonGroup, final ListItem<T> item) {
    AjaxLink add = new AjaxLink(ID_ADD) {

        @Override/*  w ww .  ja  va  2 s  . co m*/
        public void onClick(AjaxRequestTarget target) {
            addValuePerformed(target, item);
        }
    };
    add.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return isAddButtonVisible(item);
        }
    });
    buttonGroup.add(add);

    AjaxLink remove = new AjaxLink(ID_REMOVE) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            removeValuePerformed(target, item);
        }
    };
    remove.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return isRemoveButtonVisible(item);
        }
    });
    buttonGroup.add(remove);
}

From source file:com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextPanel.java

License:Apache License

protected void initPanelLayout() {
    WebMarkupContainer placeholderContainer = new WebMarkupContainer(ID_PLACEHOLDER_CONTAINER);
    placeholderContainer.setOutputMarkupPlaceholderTag(true);
    placeholderContainer.setOutputMarkupPlaceholderTag(true);
    placeholderContainer.add(new VisibleEnableBehaviour() {

        @Override/*from   w w w . j  a v  a 2s  .  com*/
        public boolean isVisible() {
            return getModel().getObject().isEmpty();
        }
    });
    add(placeholderContainer);

    AjaxLink placeholderAdd = new AjaxLink(ID_PLACEHOLDER_ADD) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            addValuePerformed(target);
        }
    };
    placeholderAdd.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (buttonsDisabled()) {
                return " " + CSS_DISABLED;
            }

            return "";
        }
    }));
    placeholderAdd.setOutputMarkupId(true);
    placeholderAdd.setOutputMarkupPlaceholderTag(true);
    placeholderContainer.add(placeholderAdd);

    ListView repeater = new ListView<T>(ID_REPEATER, getModel()) {

        @Override
        protected void populateItem(final ListItem<T> item) {
            TextField text = new TextField<>(ID_TEXT, createTextModel(item.getModel()));
            text.add(new AjaxFormComponentUpdatingBehavior("onblur") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            });
            text.add(AttributeAppender.replace("placeholder", createEmptyItemPlaceholder()));
            item.add(text);

            WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
            item.add(buttonGroup);
            initButtons(buttonGroup, item);
        }
    };
    repeater.setOutputMarkupId(true);
    repeater.setOutputMarkupPlaceholderTag(true);
    repeater.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !getModel().getObject().isEmpty();
        }
    });
    add(repeater);
}

From source file:com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextPanel.java

License:Apache License

private void initButtons(WebMarkupContainer buttonGroup, final ListItem<T> item) {
    AjaxLink plus = new AjaxLink(ID_PLUS) {

        @Override//from  ww  w  .j a  va2 s .  c  o m
        public void onClick(AjaxRequestTarget target) {
            addValuePerformed(target);
        }
    };
    plus.add(new AttributeAppender("class", getPlusClassModifier(item)));
    buttonGroup.add(plus);

    AjaxLink minus = new AjaxLink(ID_MINUS) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            removeValuePerformed(target, item);
        }
    };
    minus.add(new AttributeAppender("class", getMinusClassModifier()));
    buttonGroup.add(minus);
}

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

License:Apache License

private void initButtons(WebMarkupContainer buttonGroup, final ListItem item) {
    AjaxLink add = new AjaxLink(ID_BUTTON_ADD) {

        @Override//from  w w  w.j  a v a  2 s . c  o  m
        public void onClick(AjaxRequestTarget target) {
            addPerformed(target);
        }
    };
    add.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return isAddButtonVisible(item);
        }
    });
    buttonGroup.add(add);

    AjaxLink remove = new AjaxLink(ID_BUTTON_REMOVE) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            removePerformed(target, item);
        }
    };
    remove.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return isRemoveButtonVisible();
        }
    });
    buttonGroup.add(remove);
}

From source file:com.evolveum.midpoint.web.component.prism.CheckTableHeader.java

License:Apache License

@Override
protected void initLayout() {
    AjaxCheckBox check = new AjaxCheckBox(ID_CHECK,
            new PropertyModel<Boolean>(getModel(), ObjectWrapper.F_SELECTED)) {

        @Override/*from  w  w  w .  j av  a2 s . c om*/
        protected void onUpdate(AjaxRequestTarget target) {
        }
    };
    add(check);

    Label icon = new Label(ID_ICON);
    icon.add(AttributeModifier.replace("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return createAccountIcon();
        }
    }));
    add(icon);

    Label trigger = new Label(ID_TRIGGER);
    trigger.add(AttributeModifier.replace("title", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return createTriggerTooltip();
        }
    }));
    trigger.add(new TooltipBehavior());
    trigger.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return hasTriggers();
        }
    });
    add(trigger);

    Label protectedIcon = new Label(ID_PROTECTED);
    protectedIcon.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            ObjectWrapper wrapper = getModelObject();
            return wrapper.isProtectedAccount();
        }
    });
    add(protectedIcon);

    BootstrapLabel status = new BootstrapLabel(ID_STATUS, createStringResource("CheckTableHeader.label.error"),
            new Model(BootstrapLabel.State.DANGER));
    status.add(createFetchErrorVisibleBehaviour());
    add(status);
    AjaxLink showMore = new AjaxLink(ID_SHOW_MORE) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            onShowMorePerformed(target);
        }
    };
    showMore.add(createFetchErrorVisibleBehaviour());
    add(showMore);

    AjaxLink link = new AjaxLink(ID_LINK) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            onClickPerformed(target);
        }
    };
    add(link);

    Label name = new Label(ID_NAME, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return getDisplayName();
        }
    });
    link.add(name);

    Label description = new Label(ID_DESCRIPTION, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return getDescription();
        }
    });
    add(description);

    final IModel<List<InlineMenuItem>> items = new Model((Serializable) createMenuItems());
    InlineMenu menu = new InlineMenu(ID_MENU, items, true);
    menu.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            List<InlineMenuItem> list = items.getObject();
            return list != null && !list.isEmpty();
        }
    });
    add(menu);
}

From source file:com.evolveum.midpoint.web.component.prism.H3Header.java

License:Apache License

@Override
protected void initLayout() {
    Label title = new Label(ID_TITLE, new AbstractReadOnlyModel<String>() {

        @Override//from   ww w. j  a va 2  s . com
        public String getObject() {
            return getDisplayName();
        }
    });
    add(title);

    final IModel<List<InlineMenuItem>> items = new Model((Serializable) createMenuItems());
    InlineMenu menu = new InlineMenu(ID_MENU, items);
    menu.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            List<InlineMenuItem> list = items.getObject();
            return list != null && !list.isEmpty();
        }
    });
    add(menu);

    BootstrapLabel status = new BootstrapLabel(ID_STATUS, createStringResource("H3Header.label.error"),
            new Model(BootstrapLabel.State.DANGER));
    status.add(createFetchErrorVisibleBehaviour());
    add(status);
    AjaxLink showMore = new AjaxLink(ID_SHOW_MORE) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            onShowMorePerformed(target);
        }
    };
    showMore.add(createFetchErrorVisibleBehaviour());
    add(showMore);
}