Search in sources :

Example 6 with AjaxSubmitLink

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

the class MultiValueTextEditPanel method initButtons.

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

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            editPerformed(target, item.getModelObject());
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(getPageBase().getFeedbackPanel());
        }
    };
    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)));
    add.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
    buttonGroup.add(add);
    AjaxLink remove = new AjaxLink(ID_REMOVE) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            removeValuePerformed(target, item);
        }
    };
    remove.add(new AttributeAppender("class", getMinusClassModifier()));
    remove.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
    buttonGroup.add(remove);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Form(org.apache.wicket.markup.html.form.Form) AjaxSubmitLink(org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 7 with AjaxSubmitLink

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

the class MenuLinkPanel method initLayout.

private void initLayout(IModel<InlineMenuItem> item) {
    InlineMenuItem dto = item.getObject();
    AbstractLink a;
    if (dto.isSubmit()) {
        a = new AjaxSubmitLink(ID_MENU_ITEM_LINK) {

            @Override
            protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                MenuLinkPanel.this.onSubmit(target, form, dto.getAction(), item);
            }

            @Override
            protected void onError(AjaxRequestTarget target, Form<?> form) {
                MenuLinkPanel.this.onError(target, form, dto.getAction());
            }

            @Override
            protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
                super.updateAjaxAttributes(attributes);
                attributes.setEventPropagation(AjaxRequestAttributes.EventPropagation.BUBBLE);
            }
        };
    } else {
        a = new AjaxLink(ID_MENU_ITEM_LINK) {

            @Override
            public void onClick(AjaxRequestTarget target) {
                MenuLinkPanel.this.onClick(target, dto.getAction(), item);
            }

            @Override
            protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
                super.updateAjaxAttributes(attributes);
                attributes.setEventPropagation(AjaxRequestAttributes.EventPropagation.BUBBLE);
            }
        };
    }
    add(a);
    a.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            if (dto.getAction() == null) {
                return false;
            }
            return true;
        }
    });
    Label span = new Label(ID_MENU_ITEM_LABEL, dto.getLabel());
    span.setRenderBodyOnly(true);
    a.add(span);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) Label(org.apache.wicket.markup.html.basic.Label) AjaxSubmitLink(org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AbstractLink(org.apache.wicket.markup.html.link.AbstractLink) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 8 with AjaxSubmitLink

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

the class PageAccounts method initLinks.

private void initLinks(Form form, Form accForm) {
    AjaxSubmitLink listSyncDetails = new AjaxSubmitLink(ID_LIST_SYNC_DETAILS) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            listSyncDetailsPerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(getFeedbackPanel());
        }
    };
    form.add(listSyncDetails);
    AjaxSubmitLink export = new AjaxSubmitLink(ID_EXPORT) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            exportPerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(getFeedbackPanel());
        }
    };
    form.add(export);
    AjaxLink clearExport = new AjaxLink(ID_CLEAR_EXPORT) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            clearExportPerformed(target);
        }
    };
    accForm.add(clearExport);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Form(org.apache.wicket.markup.html.form.Form) AjaxSubmitLink(org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 9 with AjaxSubmitLink

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

the class NotificationConfigPanel method initLayout.

@Override
protected void initLayout() {
    TextField<String> defaultFromField = WebComponentUtil.createAjaxTextField(ID_DEFAULT_FROM, new PropertyModel<String>(getModel(), "defaultFrom"));
    CheckBox debugCheck = WebComponentUtil.createAjaxCheckBox(ID_DEBUG, new PropertyModel<Boolean>(getModel(), "debug"));
    DropDownChoice mailServerConfigChooser = new DropDownChoice<>(ID_MAIL_SERVER, new PropertyModel<MailServerConfigurationTypeDto>(getModel(), NotificationConfigurationDto.F_SELECTED_SERVER), new AbstractReadOnlyModel<List<MailServerConfigurationTypeDto>>() {

        @Override
        public List<MailServerConfigurationTypeDto> getObject() {
            return getModel().getObject().getServers();
        }
    }, new ChoiceableChoiceRenderer<MailServerConfigurationTypeDto>());
    mailServerConfigChooser.setNullValid(true);
    mailServerConfigChooser.add(new AjaxFormSubmitBehavior("click") {

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            getForm().onFormSubmitted();
        }
    });
    mailServerConfigChooser.add(new OnChangeAjaxBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            preparePasswordFieldPlaceholder();
            target.add(NotificationConfigPanel.this);
        }
    });
    add(mailServerConfigChooser);
    Label serverConfigTooltip = new Label(ID_MAIL_SERVER_TOOLTIP);
    serverConfigTooltip.add(new InfoTooltipBehavior());
    add(serverConfigTooltip);
    WebMarkupContainer serverConfigContainer = new WebMarkupContainer(ID_MAIL_SERVER_CONFIG_CONTAINER);
    serverConfigContainer.setOutputMarkupId(true);
    serverConfigContainer.setOutputMarkupPlaceholderTag(true);
    serverConfigContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            if (getModelObject() != null) {
                return getModelObject().getSelectedServer() != null;
            }
            return false;
        }
    });
    add(serverConfigContainer);
    TextField<String> hostField = WebComponentUtil.createAjaxTextField(ID_HOST, new PropertyModel<String>(getModel(), "selectedServer.host"));
    TextField<Integer> portField = WebComponentUtil.createAjaxTextField(ID_PORT, new PropertyModel<Integer>(getModel(), "selectedServer.port"));
    TextField<String> userNameField = WebComponentUtil.createAjaxTextField(ID_USERNAME, new PropertyModel<String>(getModel(), "selectedServer.username"));
    PasswordTextField passwordField = new PasswordTextField(ID_PASSWORD, new PropertyModel<String>(getModel(), "selectedServer.password"));
    passwordField.setRequired(false);
    passwordField.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    TextField<String> redirectToFileField = WebComponentUtil.createAjaxTextField(ID_REDIRECT_TO_FILE, new PropertyModel<String>(getModel(), "redirectToFile"));
    DropDownFormGroup transportSecurity = new DropDownFormGroup<>(ID_TRANSPORT_SECURITY, new PropertyModel<MailTransportSecurityType>(getModel(), "selectedServer.mailTransportSecurityType"), WebComponentUtil.createReadonlyModelFromEnum(MailTransportSecurityType.class), new EnumChoiceRenderer<MailTransportSecurityType>(this), createStringResource("SystemConfigPanel.mail.transportSecurity"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    // transportSecurity.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    serverConfigContainer.add(hostField);
    serverConfigContainer.add(portField);
    serverConfigContainer.add(userNameField);
    serverConfigContainer.add(passwordField);
    serverConfigContainer.add(transportSecurity);
    add(defaultFromField);
    add(debugCheck);
    add(redirectToFileField);
    AjaxSubmitLink buttonAddNewMailServerConfig = new AjaxSubmitLink(ID_BUTTON_ADD_NEW_MAIL_SERVER_CONFIG) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            MailServerConfigurationTypeDto newConfig = new MailServerConfigurationTypeDto();
            newConfig.setHost(getString("SystemConfigPanel.mail.config.placeholder"));
            if (getModelObject() != null) {
                getModelObject().getServers().add(newConfig);
                getModelObject().setSelectedServer(newConfig);
            }
            preparePasswordFieldPlaceholder();
            target.add(NotificationConfigPanel.this, getPageBase().getFeedbackPanel());
        }

        @Override
        protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            target.add(getPageBase().getFeedbackPanel());
        }
    };
    add(buttonAddNewMailServerConfig);
    AjaxSubmitLink removeMailServerConfig = new AjaxSubmitLink(ID_BUTTON_REMOVE_MAIL_SERVER_CONFIG) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            if (getModelObject() != null) {
                NotificationConfigurationDto notificationConfig = getModelObject();
                MailServerConfigurationTypeDto selected = notificationConfig.getSelectedServer();
                if (notificationConfig.getServers().contains(selected)) {
                    notificationConfig.getServers().remove(selected);
                    notificationConfig.setSelectedServer(null);
                } else {
                    warn(getString("SystemConfigPanel.mail.server.remove.warn"));
                }
                target.add(NotificationConfigPanel.this, getPageBase().getFeedbackPanel());
            }
        }

        @Override
        protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            target.add(getPageBase().getFeedbackPanel());
        }
    };
    removeMailServerConfig.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (getModelObject() != null && getModelObject().getSelectedServer() != null) {
                return null;
            } else {
                return " disabled";
            }
        }
    }));
    add(removeMailServerConfig);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) AjaxSubmitLink(org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxFormSubmitBehavior(org.apache.wicket.ajax.form.AjaxFormSubmitBehavior) MailServerConfigurationTypeDto(com.evolveum.midpoint.web.page.admin.configuration.dto.MailServerConfigurationTypeDto) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) NotificationConfigurationDto(com.evolveum.midpoint.web.page.admin.configuration.dto.NotificationConfigurationDto) DropDownFormGroup(com.evolveum.midpoint.web.component.form.DropDownFormGroup) PasswordTextField(org.apache.wicket.markup.html.form.PasswordTextField) OnChangeAjaxBehavior(org.apache.wicket.ajax.form.OnChangeAjaxBehavior) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) MailTransportSecurityType(com.evolveum.midpoint.xml.ns._public.common.common_3.MailTransportSecurityType) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) CheckBox(org.apache.wicket.markup.html.form.CheckBox)

Example 10 with AjaxSubmitLink

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

the class ExpressionEditorPanel method initLayout.

protected void initLayout(PageResourceWizard parentPage) {
    parentPage.addEditingEnabledBehavior(this);
    setOutputMarkupId(true);
    loadDtoModel();
    Label descriptionLabel = new Label(ID_LABEL_DESCRIPTION, createStringResource(getDescriptionLabelKey()));
    add(descriptionLabel);
    TextArea description = new TextArea<>(ID_DESCRIPTION, new PropertyModel<String>(dtoModel, ExpressionTypeDto.F_DESCRIPTION));
    description.setOutputMarkupId(true);
    //parentPage.addEditingEnabledBehavior(description);
    add(description);
    Label typeLabel = new Label(ID_LABEL_TYPE, createStringResource(getTypeLabelKey()));
    add(typeLabel);
    DropDownChoice type = new DropDownChoice<>(ID_TYPE, new PropertyModel<ExpressionUtil.ExpressionEvaluatorType>(dtoModel, ExpressionTypeDto.F_TYPE), WebComponentUtil.createReadonlyModelFromEnum(ExpressionUtil.ExpressionEvaluatorType.class), new EnumChoiceRenderer<ExpressionUtil.ExpressionEvaluatorType>(this));
    //parentPage.addEditingEnabledBehavior(type);
    type.add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            dtoModel.getObject().updateExpressionType();
            //target.add(get(ID_LANGUAGE_CONTAINER), get(ID_POLICY_CONTAINER), get(ID_EXPRESSION));
            // because of ACE editor
            target.add(ExpressionEditorPanel.this);
        }
    });
    type.setOutputMarkupId(true);
    type.setOutputMarkupPlaceholderTag(true);
    type.setNullValid(true);
    add(type);
    WebMarkupContainer languageContainer = new WebMarkupContainer(ID_LANGUAGE_CONTAINER);
    languageContainer.setOutputMarkupId(true);
    languageContainer.setOutputMarkupPlaceholderTag(true);
    languageContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return ExpressionUtil.ExpressionEvaluatorType.SCRIPT.equals(dtoModel.getObject().getType());
        }
    });
    //parentPage.addEditingEnabledBehavior(languageContainer);
    add(languageContainer);
    DropDownChoice language = new DropDownChoice<>(ID_LANGUAGE, new PropertyModel<ExpressionUtil.Language>(dtoModel, ExpressionTypeDto.F_LANGUAGE), WebComponentUtil.createReadonlyModelFromEnum(ExpressionUtil.Language.class), new EnumChoiceRenderer<ExpressionUtil.Language>(this));
    //parentPage.addEditingEnabledBehavior(language);
    language.add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            dtoModel.getObject().updateExpressionLanguage();
            //target.add(get(ID_LANGUAGE_CONTAINER), get(ID_POLICY_CONTAINER), get(ID_EXPRESSION));
            // because of ACE editor
            target.add(ExpressionEditorPanel.this);
        }
    });
    language.setNullValid(false);
    languageContainer.add(language);
    WebMarkupContainer policyContainer = new WebMarkupContainer(ID_POLICY_CONTAINER);
    policyContainer.setOutputMarkupId(true);
    policyContainer.setOutputMarkupPlaceholderTag(true);
    policyContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return ExpressionUtil.ExpressionEvaluatorType.GENERATE.equals(dtoModel.getObject().getType());
        }
    });
    add(policyContainer);
    DropDownChoice policyRef = new DropDownChoice<>(ID_POLICY_REF, new PropertyModel<ObjectReferenceType>(dtoModel, ExpressionTypeDto.F_POLICY_REF), new AbstractReadOnlyModel<List<ObjectReferenceType>>() {

        @Override
        public List<ObjectReferenceType> getObject() {
            return WebModelServiceUtils.createObjectReferenceList(ValuePolicyType.class, getPageBase(), policyMap);
        }
    }, new ObjectReferenceChoiceRenderer(policyMap));
    //parentPage.addEditingEnabledBehavior(policyRef);
    policyRef.add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            dtoModel.getObject().updateExpressionValuePolicyRef();
            target.add(get(ID_LANGUAGE_CONTAINER), get(ID_POLICY_CONTAINER), get(ID_EXPRESSION));
        }
    });
    policyRef.setNullValid(true);
    policyContainer.add(policyRef);
    Label expressionLabel = new Label(ID_LABEL_EXPRESSION, createStringResource(getExpressionLabelKey()));
    add(expressionLabel);
    AceEditor expression = new AceEditor(ID_EXPRESSION, new PropertyModel<String>(dtoModel, ExpressionTypeDto.F_EXPRESSION));
    expression.setOutputMarkupId(true);
    //parentPage.addEditingEnabledBehavior(expression);
    add(expression);
    AjaxSubmitLink update = new AjaxSubmitLink(ID_BUTTON_UPDATE) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            updateExpressionPerformed(target);
        }
    };
    Label updateLabel = new Label(ID_LABEL_UPDATE, createStringResource(getUpdateLabelKey()));
    updateLabel.setRenderBodyOnly(true);
    update.add(updateLabel);
    parentPage.addEditingVisibleBehavior(update);
    add(update);
    add(WebComponentUtil.createHelp(ID_T_TYPE));
    languageContainer.add(WebComponentUtil.createHelp(ID_T_LANGUAGE));
    policyContainer.add(WebComponentUtil.createHelp(ID_T_POLICY));
    add(WebComponentUtil.createHelp(ID_T_EXPRESSION));
}
Also used : ValuePolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType) TextArea(org.apache.wicket.markup.html.form.TextArea) Form(org.apache.wicket.markup.html.form.Form) Label(org.apache.wicket.markup.html.basic.Label) AceEditor(com.evolveum.midpoint.web.component.AceEditor) AjaxSubmitLink(org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice)

Aggregations

AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)16 AjaxSubmitLink (org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink)16 Label (org.apache.wicket.markup.html.basic.Label)13 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)10 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)9 List (java.util.List)8 Form (org.apache.wicket.markup.html.form.Form)8 ListItem (org.apache.wicket.markup.html.list.ListItem)8 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)8 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)7 ArrayList (java.util.ArrayList)6 MultiValueTextEditPanel (com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextEditPanel)5 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)5 QName (javax.xml.namespace.QName)4 IModel (org.apache.wicket.model.IModel)4 Model (org.apache.wicket.model.Model)4 NonEmptyModel (com.evolveum.midpoint.gui.api.model.NonEmptyModel)3 EmptyOnChangeAjaxFormUpdatingBehavior (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior)3 PageResourceWizard (com.evolveum.midpoint.web.page.admin.resources.PageResourceWizard)3 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)3