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

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

Introduction

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

Prototype

public final Component setOutputMarkupId(final boolean output) 

Source Link

Document

Sets whether or not component will output id attribute into the markup.

Usage

From source file:ch.difty.scipamato.common.web.component.table.column.LinkIconPanel.java

License:Apache License

private AjaxLink<Void> makeLink() {
    AjaxLink<Void> link = new AjaxLink<Void>(ID_LINK) {
        private static final long serialVersionUID = 1L;

        @Override/*from w w  w.  j  a v a 2s  . c  o m*/
        public void onClick(AjaxRequestTarget target) {
            onClickPerformed(target);
        }
    };
    link.add(makeImage(ID_IMAGE));
    link.setOutputMarkupId(true);
    return link;
}

From source file:com.evolveum.midpoint.gui.api.component.password.PasswordPanel.java

License:Apache License

private void initLayout(final IModel<ProtectedStringType> model, final boolean isReadOnly,
        boolean showRemoveButton) {
    setOutputMarkupId(true);/*from   w  w w .  jav a 2 s. c  o  m*/

    passwordInputVisble = model.getObject() == null;
    // TODO: remove
    //       LOGGER.trace("PASSWORD model: {}", model.getObject());

    final WebMarkupContainer inputContainer = new WebMarkupContainer(ID_INPUT_CONTAINER) {
        @Override
        public boolean isVisible() {
            return passwordInputVisble;
        }
    };
    inputContainer.setOutputMarkupId(true);
    add(inputContainer);

    final PasswordTextField password1 = new PasswordTextField(ID_PASSWORD_ONE, new PasswordModel(model));
    password1.setRequired(false);
    password1.setResetPassword(false);
    password1.setOutputMarkupId(true);
    password1.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    inputContainer.add(password1);

    final PasswordTextField password2 = new PasswordTextField(ID_PASSWORD_TWO, new Model<String>());
    password2.setRequired(false);
    password2.setResetPassword(false);
    password2.setOutputMarkupId(true);
    password2.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    inputContainer.add(password2);

    password1.add(new AjaxFormComponentUpdatingBehavior("change") {
        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            boolean required = !StringUtils.isEmpty(password1.getModel().getObject());
            password2.setRequired(required);
            //fix of MID-2463
            //            target.add(password2);
            //            target.appendJavaScript("$(\"#"+ password2.getMarkupId() +"\").focus()");
        }
    });
    password2.add(new PasswordValidator(password1, password2));

    final WebMarkupContainer linkContainer = new WebMarkupContainer(ID_LINK_CONTAINER) {
        @Override
        public boolean isVisible() {
            return !passwordInputVisble;
        }
    };
    inputContainer.setOutputMarkupId(true);
    linkContainer.setOutputMarkupId(true);
    add(linkContainer);

    final Label passwordSetLabel = new Label(ID_PASSWORD_SET, new ResourceModel("passwordPanel.passwordSet"));
    linkContainer.add(passwordSetLabel);

    final Label passwordRemoveLabel = new Label(ID_PASSWORD_REMOVE,
            new ResourceModel("passwordPanel.passwordRemoveLabel"));
    passwordRemoveLabel.setVisible(false);
    linkContainer.add(passwordRemoveLabel);

    AjaxLink link = new AjaxLink(ID_CHANGE_PASSWORD_LINK) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            onLinkClick(target);
        }

        @Override
        public boolean isVisible() {
            return !passwordInputVisble;
        }
    };
    link.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !isReadOnly;

        }
    });
    link.setBody(new ResourceModel("passwordPanel.passwordChange"));
    link.setOutputMarkupId(true);
    linkContainer.add(link);

    final WebMarkupContainer removeButtonContainer = new WebMarkupContainer(ID_REMOVE_BUTTON_CONTAINER);
    AjaxLink removePassword = new AjaxLink(ID_REMOVE_PASSWORD_LINK) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            onRemovePassword(model, target);
        }

    };
    removePassword.setVisible(showRemoveButton);
    removePassword.setBody(new ResourceModel("passwordPanel.passwordRemove"));
    removePassword.setOutputMarkupId(true);
    removeButtonContainer.add(removePassword);
    add(removeButtonContainer);
}

From source file:com.evolveum.midpoint.gui.api.component.result.OperationResultPanel.java

License:Apache License

private void initError(WebMarkupContainer operationPanel, final IModel<OpResult> model, Page parentPage) {
    Label errorLabel = new Label("errorLabel", parentPage.getString("FeedbackAlertMessageDetails.error"));
    errorLabel.add(new VisibleEnableBehaviour() {
        private static final long serialVersionUID = 1L;

        @Override//from   w  ww  .  ja  va  2s  . com
        public boolean isVisible() {
            // return true;
            return StringUtils.isNotBlank(model.getObject().getExceptionsStackTrace());

        }
    });
    errorLabel.setOutputMarkupId(true);
    operationPanel.add(errorLabel);

    Label errorMessage = new Label("errorMessage", new PropertyModel<String>(model, "exceptionMessage"));
    errorMessage.add(new VisibleEnableBehaviour() {
        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            // return true;
            return StringUtils.isNotBlank(model.getObject().getExceptionsStackTrace());

        }
    });
    errorMessage.setOutputMarkupId(true);
    operationPanel.add(errorMessage);

    final Label errorStackTrace = new Label(ID_ERROR_STACK_TRACE,
            new PropertyModel<String>(model, "exceptionsStackTrace"));
    errorStackTrace.add(new VisibleEnableBehaviour() {
        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            // return true;
            return model.getObject().isShowError();

        }
    });
    errorStackTrace.setOutputMarkupId(true);
    operationPanel.add(errorStackTrace);

    AjaxLink errorStackTraceLink = new AjaxLink("errorStackTraceLink") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            OpResult result = OperationResultPanel.this.getModelObject();
            result.setShowError(!model.getObject().isShowError());
            result.setAlreadyShown(false); // hack to be able to expand/collapse OpResult after rendered.
            //            model.getObject().setShowError(!model.getObject().isShowError());
            target.add(OperationResultPanel.this);
        }

    };
    errorStackTraceLink.setOutputMarkupId(true);
    errorStackTraceLink.add(new VisibleEnableBehaviour() {
        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return StringUtils.isNotBlank(model.getObject().getExceptionsStackTrace());

        }
    });
    operationPanel.add(errorStackTraceLink);

}

From source file:com.evolveum.midpoint.web.component.assignment.MultipleAssignmentSelector.java

License:Apache License

private Component createRowLink(String id, final IModel<SelectableBean<AssignmentEditorDto>> rowModel) {
    AjaxLink<SelectableBean<AssignmentEditorDto>> button = new AjaxLink<SelectableBean<AssignmentEditorDto>>(id,
            rowModel) {//from   w  w w  .  j a  v a2s  .  c om

        @Override
        public IModel<?> getBody() {
            AssignmentEditorDto dto = (AssignmentEditorDto) rowModel.getObject();
            String name = StringUtils.isNotEmpty(dto.getNameForTargetObject()) ? dto.getNameForTargetObject()
                    : dto.getName();
            return new Model<>(name);
        }

        @Override
        public void onClick(AjaxRequestTarget target) {
            LOGGER.trace("{} CLICK: {}", this, rowModel.getObject());
            toggleRow(rowModel);
            target.add(this);
        }

        @Override
        protected void onComponentTag(ComponentTag tag) {
            super.onComponentTag(tag);
            if (rowModel.getObject().isSelected()) {
                tag.put("class", "list-group-item active");
                tag.put("style", "background-color: #eee; border-color: #d6d6d6; color: #000;");
            } else {
                tag.put("class", "list-group-item");
            }
            String description = ((AssignmentEditorDto) rowModel.getObject()).getDescription();
            if (description != null) {
                tag.put("title", description);
            }
        }
    };
    button.add(new VisibleEnableBehaviour() {
        @Override
        public boolean isVisible() {
            return ((AssignmentEditorDto) rowModel.getObject()).getStatus() != UserDtoStatus.DELETE;
        }
    });
    button.setOutputMarkupId(true);
    return button;
}

From source file:com.evolveum.midpoint.web.component.assignment.SimpleParametricRoleSelector.java

License:Apache License

private Component createParamLink(String id, IModel<String> itemModel) {
    AjaxLink<String> button = new AjaxLink<String>(id, itemModel) {

        @Override//from w  w w  .  j  a  v  a  2s  .  c om
        public IModel<?> getBody() {
            return new Model<String>(getModel().getObject());
        }

        @Override
        public void onClick(AjaxRequestTarget target) {
            LOGGER.trace("{} CLICK param: {}", this, getModel().getObject());
            toggleParam(getModel().getObject());
            target.add(SimpleParametricRoleSelector.this);
        }

        @Override
        protected void onComponentTag(ComponentTag tag) {
            super.onComponentTag(tag);
            String param = getModel().getObject();
            if (param.equals(selectedParam)) {
                tag.put("class", "list-group-item active");
            } else {
                tag.put("class", "list-group-item");
            }
        }
    };
    button.setOutputMarkupId(true);
    return button;
}

From source file:com.evolveum.midpoint.web.component.assignment.SimpleRoleSelector.java

License:Apache License

private Component createRoleLink(String id, IModel<PrismObject<R>> model) {
    AjaxLink<PrismObject<R>> button = new AjaxLink<PrismObject<R>>(id, model) {

        @Override//  w  w w.ja  va  2  s. c  om
        public IModel<?> getBody() {
            return new Model<String>(getModel().getObject().asObjectable().getName().getOrig());
        }

        @Override
        public void onClick(AjaxRequestTarget target) {
            LOGGER.trace("{} CLICK: {}", this, getModel().getObject());
            toggleRole(getModel().getObject());
            target.add(this);
        }

        @Override
        protected void onComponentTag(ComponentTag tag) {
            super.onComponentTag(tag);
            PrismObject<R> role = getModel().getObject();
            if (isSelected(role)) {
                tag.put("class", "list-group-item active");
            } else {
                tag.put("class", "list-group-item");
            }
            String description = role.asObjectable().getDescription();
            if (description != null) {
                tag.put("title", description);
            }
        }
    };
    button.setOutputMarkupId(true);
    return button;
}

From source file:com.evolveum.midpoint.web.component.assignment.UserSelectionButton.java

License:Apache License

private void initLayout() {
    AjaxLink<String> userSelectionButton = new AjaxLink<String>(ID_USER_SELECTION_BUTTON) {
        private static final long serialVersionUID = 1L;

        @Override/*from  w ww .  j  ava 2s.  com*/
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            attributes.setEventPropagation(AjaxRequestAttributes.EventPropagation.BUBBLE);
        }

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (showUserSelectionPopup) {
                initUserSelectionPopup(target);
            }
            showUserSelectionPopup = true;
        }
    };
    userSelectionButton.add(AttributeModifier.append("class", getTargetUserButtonClass()));
    userSelectionButton.setOutputMarkupId(true);
    userSelectionButton.add(new AttributeAppender("title", new IModel<String>() {
        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return getUserSelectionButtonTitle();
        }
    }));
    add(userSelectionButton);

    Label label = new Label(ID_USER_SELECTION_BUTTON_LABEL, new IModel<String>() {
        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return getUserButtonLabel();
        }
    });
    label.setRenderBodyOnly(true);
    userSelectionButton.add(label);

    AjaxLink deleteButton = new AjaxLink(ID_DELETE_SELECTED_USER_BUTTON) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            UserSelectionButton.this.onDeleteSelectedUsersPerformed(target);
        }
    };
    deleteButton.add(new VisibleEnableBehaviour() {
        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isDeleteButtonVisible();
        }
    });
    userSelectionButton.add(deleteButton);
}

From source file:com.evolveum.midpoint.web.component.data.column.LinkIconPanel.java

License:Apache License

private void initLayout(IModel<String> model, IModel<String> titleModel) {
    AjaxLink link = new AjaxLink(ID_LINK) {

        @Override// w w w  . ja  v a2  s.co m
        public void onClick(AjaxRequestTarget target) {
            onClickPerformed(target);
        }
    };

    Label image = new Label(ID_IMAGE);
    image.add(AttributeModifier.replace("class", model));
    if (titleModel != null) {
        image.add(AttributeModifier.replace("title", titleModel));
    }
    link.add(image);
    link.setOutputMarkupId(true);
    add(link);
}

From source file:com.evolveum.midpoint.web.component.form.multivalue.MultiValueAutoCompleteTextPanel.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 av a 2s .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) {
            AutoCompleteSettings autoCompleteSettings = new AutoCompleteSettings();
            autoCompleteSettings.setShowListOnEmptyInput(true);
            AutoCompleteTextField<String> autoCompleteEditor = new AutoCompleteTextField<String>(ID_TEXT,
                    createTextModel(item.getModel()), autoCompleteSettings) {

                @Override
                protected Iterator<String> getChoices(String input) {
                    return createAutoCompleteObjectList(input);
                }
            };
            autoCompleteEditor.add(createAutoCompleteValidator());
            autoCompleteEditor.add(new AjaxFormComponentUpdatingBehavior("onchange") {

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            });
            item.add(autoCompleteEditor);

            autoCompleteEditor.add(AttributeAppender.replace("placeholder", createEmptyItemPlaceholder()));

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

            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.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  ww w .jav 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) {

            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);
}