Search in sources :

Example 21 with AjaxLink

use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.

the class NavigatorPanel method initNext.

private void initNext() {
    WebMarkupContainer next = new WebMarkupContainer(ID_NEXT);
    next.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return isNextEnabled() ? "" : "disabled";
        }
    }));
    add(next);
    AjaxLink nextLink = new AjaxLink(ID_NEXT_LINK) {

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            attributes.setChannel(new AjaxChannel("blocking", AjaxChannel.Type.ACTIVE));
        }

        @Override
        public void onClick(AjaxRequestTarget target) {
            nextPerformed(target);
        }
    };
    nextLink.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return isNextEnabled();
        }
    });
    next.add(nextLink);
}
Also used : AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) AjaxChannel(org.apache.wicket.ajax.AjaxChannel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AttributeModifier(org.apache.wicket.AttributeModifier) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 22 with AjaxLink

use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.

the class TargetUserSelectorComponent method initLayout.

private void initLayout() {
    AjaxLink<String> targetUserButton = new AjaxLink<String>(ID_TARGET_USER_BUTTON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (showUserSelectionPopup) {
                initUserSelectionPopup(createStringResource("AssignmentCatalogPanel.selectTargetUser"), true, target);
            }
            showUserSelectionPopup = true;
        }
    };
    targetUserButton.add(new AttributeAppender("class", "btn btn-default" + (StringUtils.isEmpty(additionalButtonStyle) ? "" : " " + additionalButtonStyle)));
    targetUserButton.setOutputMarkupId(true);
    targetUserButton.add(new AttributeAppender("title", getTargetUsersButtonTitle()));
    add(targetUserButton);
    Label label = new Label(ID_TARGET_USER_LABEL, createStringResource("AssignmentCatalogPanel.selectTargetUser"));
    label.setRenderBodyOnly(true);
    targetUserButton.add(label);
    AjaxLink deleteButton = new AjaxLink(ID_DELETE_TARGET_USER_BUTTON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            showUserSelectionPopup = false;
            getRoleCatalogStorage().setTargetUserList(null);
            target.add(pageBase);
        }
    };
    deleteButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getRoleCatalogStorage().getTargetUserList() != null && getRoleCatalogStorage().getTargetUserList().size() > 0;
        }
    });
    targetUserButton.add(deleteButton);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Label(org.apache.wicket.markup.html.basic.Label) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 23 with AjaxLink

use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.

the class RunReportPopupPanel method createInputMarkup.

private WebMarkupContainer createInputMarkup(final IModel<JasperReportValueDto> valueModel, JasperReportParameterDto param) {
    param.setEditing(true);
    WebMarkupContainer paramValueMarkup = new WebMarkupContainer("valueMarkup");
    paramValueMarkup.setOutputMarkupId(true);
    InputPanel input = createTypedInputPanel("inputValue", valueModel, "value", param);
    paramValueMarkup.add(input);
    //buttons
    AjaxLink<String> addButton = new AjaxLink<String>(ID_ADD_BUTTON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            addValue(paramValueMarkup, param, target);
        }
    };
    addButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isAddButtonVisible(param);
        }
    });
    paramValueMarkup.add(addButton);
    AjaxLink<String> removeButton = new AjaxLink<String>(ID_REMOVE_BUTTON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            removeValue(paramValueMarkup, param, valueModel.getObject(), target);
        }
    };
    removeButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isRemoveButtonVisible();
        }
    });
    paramValueMarkup.add(removeButton);
    return paramValueMarkup;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InputPanel(com.evolveum.midpoint.web.component.prism.InputPanel) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 24 with AjaxLink

use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.

the class PageBase method initTitleLayout.

private void initTitleLayout(WebMarkupContainer mainHeader) {
    WebMarkupContainer pageTitleContainer = new WebMarkupContainer(ID_PAGE_TITLE_CONTAINER);
    pageTitleContainer.add(createUserStatusBehaviour(true));
    mainHeader.add(pageTitleContainer);
    WebMarkupContainer pageTitle = new WebMarkupContainer(ID_PAGE_TITLE);
    pageTitleContainer.add(pageTitle);
    String environmentName = "";
    if (deploymentInfoModel != null && deploymentInfoModel.getObject() != null && StringUtils.isNotEmpty(deploymentInfoModel.getObject().getName())) {
        environmentName = deploymentInfoModel.getObject().getName();
    }
    Model<String> deploymentNameModel = new Model<String>(StringUtils.isNotEmpty(environmentName) ? environmentName + ": " : "");
    Label deploymentName = new Label(ID_DEPLOYMENT_NAME, deploymentNameModel);
    deploymentName.add(new VisibleEnableBehaviour() {

        public boolean isVisible() {
            return StringUtils.isNotEmpty(deploymentNameModel.getObject());
        }
    });
    deploymentName.setRenderBodyOnly(true);
    pageTitle.add(deploymentName);
    Label pageTitleReal = new Label(ID_PAGE_TITLE_REAL, createPageTitleModel());
    pageTitleReal.setRenderBodyOnly(true);
    pageTitle.add(pageTitleReal);
    ListView breadcrumbs = new ListView<Breadcrumb>(ID_BREADCRUMB, new AbstractReadOnlyModel<List<Breadcrumb>>() {

        private static final long serialVersionUID = 1L;

        @Override
        public List<Breadcrumb> getObject() {
            return getBreadcrumbs();
        }
    }) {

        @Override
        protected void populateItem(ListItem<Breadcrumb> item) {
            final Breadcrumb dto = item.getModelObject();
            AjaxLink bcLink = new AjaxLink(ID_BC_LINK) {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    redirectBackToBreadcrumb(dto);
                }
            };
            item.add(bcLink);
            bcLink.add(new VisibleEnableBehaviour() {

                private static final long serialVersionUID = 1L;

                @Override
                public boolean isEnabled() {
                    return dto.isUseLink();
                }
            });
            WebMarkupContainer bcIcon = new WebMarkupContainer(ID_BC_ICON);
            bcIcon.add(new VisibleEnableBehaviour() {

                private static final long serialVersionUID = 1L;

                @Override
                public boolean isVisible() {
                    return dto.getIcon() != null && dto.getIcon().getObject() != null;
                }
            });
            bcIcon.add(AttributeModifier.replace("class", dto.getIcon()));
            bcLink.add(bcIcon);
            Label bcName = new Label(ID_BC_NAME, dto.getLabel());
            bcLink.add(bcName);
            item.add(new VisibleEnableBehaviour() {

                private static final long serialVersionUID = 1L;

                @Override
                public boolean isVisible() {
                    return dto.isVisible();
                }
            });
        }
    };
    mainHeader.add(breadcrumbs);
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) Breadcrumb(com.evolveum.midpoint.web.component.breadcrumbs.Breadcrumb) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListView(org.apache.wicket.markup.html.list.ListView) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) StringResourceModel(org.apache.wicket.model.StringResourceModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ListItem(org.apache.wicket.markup.html.list.ListItem) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 25 with AjaxLink

use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.

the class PasswordPanel method initLayout.

private void initLayout(final IModel<ProtectedStringType> model, final boolean isReadOnly) {
    setOutputMarkupId(true);
    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.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            PageBase pageBase = (PageBase) getPage();
            if (pageBase == null) {
                return false;
            }
            if (pageBase instanceof PageSelfProfile) {
                return false;
            }
            if (pageBase instanceof PageUser && model.getObject() != null && !model.getObject().isEmpty()) {
                return true;
            }
            return false;
        }
    });
    removePassword.setBody(new ResourceModel("passwordPanel.passwordRemove"));
    removePassword.setOutputMarkupId(true);
    removeButtonContainer.add(removePassword);
    add(removeButtonContainer);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) Label(org.apache.wicket.markup.html.basic.Label) PasswordTextField(org.apache.wicket.markup.html.form.PasswordTextField) PageSelfProfile(com.evolveum.midpoint.web.page.self.PageSelfProfile) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PageUser(com.evolveum.midpoint.web.page.admin.users.PageUser) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ResourceModel(org.apache.wicket.model.ResourceModel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Aggregations

AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)81 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)80 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)50 Label (org.apache.wicket.markup.html.basic.Label)48 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)44 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)28 ListItem (org.apache.wicket.markup.html.list.ListItem)21 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)17 ListView (org.apache.wicket.markup.html.list.ListView)17 TextField (org.apache.wicket.markup.html.form.TextField)15 ArrayList (java.util.ArrayList)13 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)13 AttributeModifier (org.apache.wicket.AttributeModifier)12 List (java.util.List)11 Form (org.apache.wicket.markup.html.form.Form)11 AjaxSubmitLink (org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink)10 IModel (org.apache.wicket.model.IModel)9 Model (org.apache.wicket.model.Model)8 ComponentFeedbackMessageFilter (org.apache.wicket.feedback.ComponentFeedbackMessageFilter)6 FeedbackPanel (org.apache.wicket.markup.html.panel.FeedbackPanel)6