Package org.apache.wicket.markup.html.form

Examples of org.apache.wicket.markup.html.form.Form$FormValidatorRemovedChange


    public StatusModalPage(final PageReference pageRef, final ModalWindow window,
            final AbstractAttributableTO attributable) {

        super();

        final Form form = new Form("form");
        add(form);

        final List<StatusBean> statuses = new ArrayList<StatusBean>();

        final StatusPanel statusPanel = new StatusPanel("statuspanel", attributable, statuses, null);
        MetaDataRoleAuthorizationStrategy.authorize(
                statusPanel, RENDER, xmlRolesReader.getAllAllowedRoles("Resources", "getConnectorObject"));
        form.add(statusPanel);

        final AjaxButton disable;
        if (attributable instanceof UserTO) {
            disable = new IndicatingAjaxButton("disable", new ResourceModel("disable", "Disable")) {

                private static final long serialVersionUID = -958724007591692537L;

                @Override
                protected void onSubmit(final AjaxRequestTarget target, final Form form) {
                    try {
                        userRestClient.suspend(attributable.getId(), statuses);

                        if (pageRef.getPage() instanceof BasePage) {
                            ((BasePage) pageRef.getPage()).setModalResult(true);
                        }

                        window.close(target);
                    } catch (Exception e) {
                        LOG.error("Error disabling resources", e);
                        error(getString("error") + ":" + e.getMessage());
                        target.add(feedbackPanel);
                    }
                }

                @Override
                protected void onError(final AjaxRequestTarget target, final Form<?> form) {
                    target.add(feedbackPanel);
                }
            };
        } else {
            disable = new AjaxButton("disable") {

                private static final long serialVersionUID = 5538299138211283825L;

            };
            disable.setVisible(false);
        }
        form.add(disable);

        final AjaxButton enable;
        if (attributable instanceof UserTO) {
            enable = new IndicatingAjaxButton("enable", new ResourceModel("enable", "Enable")) {

                private static final long serialVersionUID = -958724007591692537L;

                @Override
                protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
                    try {
                        userRestClient.reactivate(attributable.getId(), statuses);

                        ((BasePage) pageRef.getPage()).setModalResult(true);

                        window.close(target);
                    } catch (Exception e) {
                        LOG.error("Error enabling resources", e);
                        error(getString("error") + ":" + e.getMessage());
                        target.add(feedbackPanel);
                    }
                }

                @Override
                protected void onError(final AjaxRequestTarget target, final Form<?> form) {

                    target.add(feedbackPanel);
                }
            };
        } else {
            enable = new AjaxButton("enable") {

                private static final long serialVersionUID = 5538299138211283825L;

            };
            enable.setVisible(false);
        }
        form.add(enable);

        final AjaxButton cancel = new IndicatingAjaxButton("cancel", new ResourceModel("cancel")) {

            private static final long serialVersionUID = -958724007591692537L;

            @Override
            protected void onSubmit(final AjaxRequestTarget target, final Form form) {
                window.close(target);
            }
        };
        cancel.setDefaultFormProcessing(false);
        form.add(cancel);
    }
View Full Code Here


    private SchemaRestClient schemaRestClient;

    public NotificationModalPage(final PageReference pageRef, final ModalWindow window,
            final NotificationTO notificationTO, final boolean createFlag) {

        Form form = new Form("form", new CompoundPropertyModel(notificationTO));
        form.setModel(new CompoundPropertyModel(notificationTO));

        final AjaxTextFieldPanel sender = new AjaxTextFieldPanel("sender", getString("sender"),
                new PropertyModel<String>(notificationTO, "sender"));
        sender.addRequiredLabel();
        sender.addValidator(EmailAddressValidator.getInstance());
        form.add(sender);

        final AjaxTextFieldPanel subject = new AjaxTextFieldPanel("subject", getString("subject"),
                new PropertyModel<String>(notificationTO, "subject"));
        subject.addRequiredLabel();
        form.add(subject);

        final AjaxDropDownChoicePanel<String> template = new AjaxDropDownChoicePanel<String>("template",
                getString("template"), new PropertyModel(notificationTO, "template"));
        template.setChoices(restClient.getMailTemplates());
        template.addRequiredLabel();
        form.add(template);

        final AjaxDropDownChoicePanel<TraceLevel> traceLevel = new AjaxDropDownChoicePanel<TraceLevel>("traceLevel",
                getString("traceLevel"), new PropertyModel(notificationTO, "traceLevel"));
        traceLevel.setChoices(Arrays.asList(TraceLevel.values()));
        traceLevel.addRequiredLabel();
        form.add(traceLevel);

        final UserSearchPanel about = new UserSearchPanel("about", notificationTO.getAbout());
        form.add(about);

        final AjaxDropDownChoicePanel<IntMappingType> recipientAttrType = new AjaxDropDownChoicePanel<IntMappingType>(
                "recipientAttrType",
                new ResourceModel("recipientAttrType", "recipientAttrType").getObject(),
                new PropertyModel<IntMappingType>(notificationTO, "recipientAttrType"));

        final Set<IntMappingType> toBeFiltered = new HashSet<IntMappingType>();
        toBeFiltered.add(IntMappingType.UserId);
        toBeFiltered.add(IntMappingType.Password);

        recipientAttrType.setChoices(new ArrayList<IntMappingType>(
                (Set<IntMappingType>) IntMappingType.getAttributeTypes(AttributableType.USER, toBeFiltered)));

        recipientAttrType.setRequired(true);
        form.add(recipientAttrType);

        final AjaxDropDownChoicePanel<String> recipientAttrName = new AjaxDropDownChoicePanel<String>(
                "recipientAttrName",
                new ResourceModel("recipientAttrName", "recipientAttrName").getObject(),
                new PropertyModel(notificationTO, "recipientAttrName"));

        recipientAttrName.setChoices(getSchemaNames(notificationTO.getRecipientAttrType()));
        recipientAttrName.setRequired(true);
        form.add(recipientAttrName);

        recipientAttrType.getField().add(new AjaxFormComponentUpdatingBehavior(ON_CHANGE) {

            private static final long serialVersionUID = -1107858522700306810L;

            @Override
            protected void onUpdate(final AjaxRequestTarget target) {
                recipientAttrName.setChoices(getSchemaNames(notificationTO.getRecipientAttrType()));
                target.add(recipientAttrName);
            }
        });

        final AjaxPalettePanel events = new AjaxPalettePanel("events", new PropertyModel(notificationTO, "events"),
                new ListModel<String>(restClient.getEvents()));
        form.add(events);

        final WebMarkupContainer recipientsContainer = new WebMarkupContainer("recipientsContainer");
        recipientsContainer.setOutputMarkupId(true);

        form.add(recipientsContainer);

        final AjaxCheckBoxPanel selfAsRecipient = new AjaxCheckBoxPanel("selfAsRecipient",
                getString("selfAsRecipient"), new PropertyModel(notificationTO, "selfAsRecipient"));
        form.add(selfAsRecipient);

        if (createFlag) {
            selfAsRecipient.getField().setDefaultModelObject(Boolean.TRUE);
        }

        final AjaxCheckBoxPanel checkRecipients =
                new AjaxCheckBoxPanel("checkRecipients", "checkRecipients",
                new Model<Boolean>(notificationTO.getRecipients() == null ? false : true));
        recipientsContainer.add(checkRecipients);

        final UserSearchPanel recipients =
                new UserSearchPanel("recipients",
                notificationTO.getRecipients() == null ? null : notificationTO.getRecipients());
        recipientsContainer.add(recipients);
        recipients.setEnabled(checkRecipients.getModelObject());

        selfAsRecipient.getField().add(new AjaxFormComponentUpdatingBehavior(ON_CHANGE) {

            private static final long serialVersionUID = -1107858522700306810L;

            @Override
            protected void onUpdate(final AjaxRequestTarget target) {
                if (!Boolean.valueOf(selfAsRecipient.getField().getValue())) {
                    checkRecipients.getField().setDefaultModelObject(Boolean.TRUE);
                    target.add(checkRecipients);
                    recipients.setEnabled(checkRecipients.getModelObject());
                    target.add(recipients);
                    target.add(recipientsContainer);
                }
            }
        });

        checkRecipients.getField().add(new AjaxFormComponentUpdatingBehavior(ON_CHANGE) {

            private static final long serialVersionUID = -1107858522700306810L;

            @Override
            protected void onUpdate(final AjaxRequestTarget target) {
                if (!checkRecipients.getModelObject()) {
                    selfAsRecipient.getField().setDefaultModelObject(Boolean.TRUE);
                    target.add(selfAsRecipient);
                }
                recipients.setEnabled(checkRecipients.getModelObject());
                target.add(recipients);
                target.add(recipientsContainer);
            }
        });

        AjaxButton submit = new IndicatingAjaxButton("apply", new Model<String>(getString("submit"))) {

            private static final long serialVersionUID = -958724007591692537L;

            @Override
            protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
                notificationTO.setAbout(about.buildSearchCond());
                notificationTO.setRecipients(checkRecipients.getModelObject() ? recipients.buildSearchCond() : null);

                try {
                    if (createFlag) {
                        restClient.createNotification(notificationTO);
                    } else {
                        restClient.updateNotification(notificationTO);
                    }
                    info(getString("operation_succeeded"));

                    Configuration callerPage = (Configuration) pageRef.getPage();
                    callerPage.setModalResult(true);

                    window.close(target);
                } catch (SyncopeClientCompositeErrorException scee) {
                    error(getString("error") + ":" + scee.getMessage());
                    target.add(feedbackPanel);
                }
            }

            @Override
            protected void onError(final AjaxRequestTarget target, final Form<?> form) {

                target.add(feedbackPanel);
            }
        };

        final AjaxButton cancel = new IndicatingAjaxButton("cancel", new ResourceModel("cancel")) {

            private static final long serialVersionUID = -958724007591692537L;

            @Override
            protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
                window.close(target);
            }
        };

        cancel.setDefaultFormProcessing(false);

        String allowedRoles = createFlag
                ? xmlRolesReader.getAllAllowedRoles("Notification", "create")
                : xmlRolesReader.getAllAllowedRoles("Notification", "update");
        MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, allowedRoles);

        form.add(submit);
        form.setDefaultButton(submit);

        form.add(cancel);

        add(form);
    }
View Full Code Here

    private AjaxButton submit;

    public MembershipModalPage(final PageReference pageRef, final ModalWindow window, final MembershipTO membershipTO,
            final boolean templateMode) {

        final Form form = new Form("MembershipForm");

        final UserTO userTO = ((UserModalPage) pageRef.getPage()).getUserTO();

        form.setModel(new CompoundPropertyModel(membershipTO));

        submit = new AjaxButton("submit", new ResourceModel("submit")) {

            private static final long serialVersionUID = -958724007591692537L;

            @Override
            protected void onSubmit(final AjaxRequestTarget target, final Form form) {
                userTO.removeMembership(membershipTO);
                userTO.addMembership(membershipTO);

                ((UserModalPage) pageRef.getPage()).setUserTO(userTO);

                window.close(target);
            }

            @Override
            protected void onError(final AjaxRequestTarget target, final Form<?> form) {
                target.add(feedbackPanel);
            }
        };

        form.add(submit);

        final IndicatingAjaxButton cancel = new IndicatingAjaxButton("cancel", new ResourceModel("cancel")) {

            private static final long serialVersionUID = -958724007591692537L;

            @Override
            protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
                window.close(target);
            }

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

        cancel.setDefaultFormProcessing(false);
        form.add(cancel);

        //--------------------------------
        // Attributes panel
        //--------------------------------
        form.add(new AttributesPanel("attributes", membershipTO, form, templateMode));
        //--------------------------------

        //--------------------------------
        // Derived attributes container
        //--------------------------------
        form.add(new DerivedAttributesPanel("derivedAttributes", membershipTO));
        //--------------------------------

        //--------------------------------
        // Virtual attributes container
        //--------------------------------
        form.add(new VirtualAttributesPanel("virtualAttributes", membershipTO, templateMode));
        //--------------------------------

        add(form);
    }
View Full Code Here

    private PolicyRestClient policyRestClient;

    public PolicyModalPage(final ModalWindow window, final T policyTO, final PageReference pageRef) {
        super();

        final Form form = new Form("form");
        form.setOutputMarkupId(true);
        add(form);

        final AjaxTextFieldPanel policyid = new AjaxTextFieldPanel("id", "id",
                new PropertyModel<String>(policyTO, "id"));
        policyid.setEnabled(false);
        policyid.setStyleSheet("ui-widget-content ui-corner-all short_fixedsize");
        form.add(policyid);

        final AjaxTextFieldPanel description = new AjaxTextFieldPanel("description", "description",
                new PropertyModel<String>(policyTO, "description"));
        description.addRequiredLabel();
        description.setStyleSheet("ui-widget-content ui-corner-all medium_dynamicsize");
        form.add(description);

        final AjaxDropDownChoicePanel<PolicyType> type = new AjaxDropDownChoicePanel<PolicyType>("type", "type",
                new PropertyModel<PolicyType>(policyTO, "type"));

        switch (policyTO.getType()) {
            case GLOBAL_ACCOUNT:
            case ACCOUNT:
                type.setChoices(Arrays.asList(new PolicyType[] {PolicyType.GLOBAL_ACCOUNT, PolicyType.ACCOUNT}));
                break;

            case GLOBAL_PASSWORD:
            case PASSWORD:
                type.setChoices(Arrays.asList(new PolicyType[] {PolicyType.GLOBAL_PASSWORD, PolicyType.PASSWORD}));
                break;

            case GLOBAL_SYNC:
            case SYNC:
                type.setChoices(Arrays.asList(new PolicyType[] {PolicyType.GLOBAL_SYNC, PolicyType.SYNC}));

            default:
        }

        type.setChoiceRenderer(new PolicyTypeRenderer());

        type.addRequiredLabel();
        form.add(type);

        final AbstractPolicySpec policy = getPolicySpecification(policyTO);

        form.add(new PolicyBeanPanel("panel", policy));

        final AjaxButton submit = new IndicatingAjaxButton("apply", new ResourceModel("apply")) {

            private static final long serialVersionUID = -958724007591692537L;

            @Override
            protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
                setPolicySpecification(policyTO, policy);

                try {
                    if (policyTO.getId() > 0) {
                        policyRestClient.updatePolicy(policyTO);
                    } else {
                        policyRestClient.createPolicy(policyTO);
                    }

                    window.close(target);
                } catch (Exception e) {
                    LOG.error("While creating policy", e);

                    error(getString("error") + ":" + e.getMessage());
                    target.add(getPage().get("feedback"));
                }
            }

            @Override
            protected void onError(final AjaxRequestTarget target, final Form<?> form) {
                target.add(getPage().get("feedback"));
            }
        };

        form.add(submit);

        final IndicatingAjaxButton cancel = new IndicatingAjaxButton("cancel", new ResourceModel("cancel")) {

            private static final long serialVersionUID = -958724007591692537L;

            @Override
            protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
                window.close(target);
            }

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

        cancel.setDefaultFormProcessing(false);
        form.add(cancel);
    }
View Full Code Here

        this.add(new Label("name", StringUtils.isBlank(resourceTO.getName())
                ? ""
                : resourceTO.getName()));

        final Form form = new Form("form");
        form.setModel(new CompoundPropertyModel(resourceTO));

        //--------------------------------
        // Resource details panel
        //--------------------------------
        form.add(new ResourceDetailsPanel("details", resourceTO,
                restClient.getPropagationActionsClasses(), createFlag));
        //--------------------------------

        //--------------------------------
        // Resource mapping panels
        //--------------------------------
        form.add(new ResourceMappingPanel("umapping", resourceTO, AttributableType.USER));
        form.add(new ResourceMappingPanel("rmapping", resourceTO, AttributableType.ROLE));
        //--------------------------------

        //--------------------------------
        // Resource mapping panel
        //--------------------------------
        form.add(new ResourceConnConfPanel("connconf", resourceTO, createFlag));
        //--------------------------------

        //--------------------------------
        // Resource security panel
        //--------------------------------
        form.add(new ResourceSecurityPanel("security", resourceTO));
        //--------------------------------

        final AjaxButton submit = new IndicatingAjaxButton("apply", new ResourceModel("submit", "submit")) {

            private static final long serialVersionUID = -958724007591692537L;

            @Override
            protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
                final ResourceTO resourceTO = (ResourceTO) form.getDefaultModelObject();

                boolean accountIdError = false;

                if (resourceTO.getUmapping().getItems().isEmpty()) {
                    resourceTO.setUmapping(null);
                } else {
                    int uAccountIdCount = 0;
                    for (MappingItemTO item : resourceTO.getUmapping().getItems()) {
                        if (item.isAccountid()) {
                            uAccountIdCount++;
                        }
                    }
                    accountIdError = uAccountIdCount != 1;
                }

                if (resourceTO.getRmapping().getItems().isEmpty()) {
                    resourceTO.setRmapping(null);
                } else {
                    int rAccountIdCount = 0;
                    for (MappingItemTO item : resourceTO.getRmapping().getItems()) {
                        if (item.isAccountid()) {
                            rAccountIdCount++;
                        }
                    }
                    accountIdError |= rAccountIdCount != 1;
                }

                if (accountIdError) {
                    error(getString("accountIdValidation"));
                    target.add(feedbackPanel);
                } else {
                    try {
                        if (createFlag) {
                            restClient.create(resourceTO);
                        } else {
                            restClient.update(resourceTO);
                        }

                        ((Resources) pageRef.getPage()).setModalResult(true);
                        window.close(target);
                    } catch (Exception e) {
                        LOG.error("Failure managing resource {}", resourceTO, e);
                        error(getString("error") + ": " + e.getMessage());
                        target.add(feedbackPanel);
                    }
                }
            }

            @Override
            protected void onError(final AjaxRequestTarget target, final Form<?> form) {
                target.add(feedbackPanel);
            }
        };

        form.add(submit);
        form.setDefaultButton(submit);

        final AjaxButton cancel = new IndicatingAjaxButton("cancel", new ResourceModel("cancel")) {

            private static final long serialVersionUID = -958724007591692537L;

            @Override
            protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
                window.close(target);
            }

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

        cancel.setDefaultFormProcessing(false);
        form.add(cancel);

        add(form);

        MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, xmlRolesReader.getAllAllowedRoles("Resources",
                createFlag
View Full Code Here

        final ModalWindow taskExecMessageWin = new ModalWindow("taskExecMessageWin");
        taskExecMessageWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
        taskExecMessageWin.setCookieName("task-exec-message-win-modal");
        add(taskExecMessageWin);

        form = new Form("form");
        form.setModel(new CompoundPropertyModel(taskTO));
        add(form);

        profile = new WebMarkupContainer("profile");
        profile.setOutputMarkupId(true);
View Full Code Here

        window.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
        window.setInitialHeight(WIN_HEIGHT);
        window.setInitialWidth(WIN_WIDTH);
        window.setCookieName("view-task-win");

        Form paginatorForm = new Form("PaginatorForm");

        final DropDownChoice rowsChooser = new DropDownChoice("rowsChooser", new PropertyModel(this, "paginatorRows"),
                prefMan.getPaginatorChoices());

        rowsChooser.add(new AjaxFormComponentUpdatingBehavior("onchange") {

            private static final long serialVersionUID = -1107858522700306810L;

            @Override
            protected void onUpdate(final AjaxRequestTarget target) {
                prefMan.set(getWebRequest(), (WebResponse) getResponse(),
                        Constants.PREF_NOTIFICATION_TASKS_PAGINATOR_ROWS, String.valueOf(paginatorRows));

                table = Tasks.updateTaskTable(
                        columns,
                        new TasksProvider<NotificationTaskTO>(restClient, paginatorRows, getId(),
                        NotificationTaskTO.class),
                        container,
                        table == null ? 0 : (int) table.getCurrentPage(),
                        pageRef,
                        restClient);

                target.add(container);
            }
        });

        paginatorForm.add(rowsChooser);
        add(paginatorForm);
    }
View Full Code Here

                pageRef,
                restClient);

        container.add(table);

        Form paginatorForm = new Form("PaginatorForm");

        final DropDownChoice rowsChooser = new DropDownChoice("rowsChooser", new PropertyModel(this, "paginatorRows"),
                prefMan.getPaginatorChoices());

        rowsChooser.add(new AjaxFormComponentUpdatingBehavior("onchange") {

            private static final long serialVersionUID = -1107858522700306810L;

            @Override
            protected void onUpdate(final AjaxRequestTarget target) {
                prefMan.set(getWebRequest(), (WebResponse) getResponse(), Constants.PREF_SCHED_TASKS_PAGINATOR_ROWS,
                        String.valueOf(paginatorRows));

                table = Tasks.updateTaskTable(
                        columns,
                        new TasksProvider<SchedTaskTO>(restClient, paginatorRows, getId(), SchedTaskTO.class),
                        container,
                        table == null ? 0 : (int) table.getCurrentPage(),
                        pageRef,
                        restClient);

                target.add(container);
            }
        });

        paginatorForm.add(rowsChooser);
        add(paginatorForm);

        AjaxLink createLink = new ClearIndicatingAjaxLink("createLink", pageRef) {

            private static final long serialVersionUID = -7978723352517770644L;
View Full Code Here

    private static String onchange = "onchange";

    public NotificationModalPage(final PageReference callPageRef, final ModalWindow window,
            final NotificationTO notificationTO, final boolean createFlag) {

        Form form = new Form("form", new CompoundPropertyModel(notificationTO));
        form.setModel(new CompoundPropertyModel(notificationTO));

        final AjaxTextFieldPanel sender = new AjaxTextFieldPanel("sender", getString("sender"),
                new PropertyModel<String>(notificationTO, "sender"));
        sender.addRequiredLabel();
        sender.addValidator(EmailAddressValidator.getInstance());
        form.add(sender);

        final AjaxTextFieldPanel subject = new AjaxTextFieldPanel("subject", getString("subject"),
                new PropertyModel<String>(notificationTO, "subject"));
        subject.addRequiredLabel();
        form.add(subject);

        final AjaxDropDownChoicePanel<String> template = new AjaxDropDownChoicePanel<String>("template",
                getString("template"), new PropertyModel(notificationTO, "template"));
        template.setChoices(restClient.getMailTemplates());
        template.addRequiredLabel();
        form.add(template);

        final AjaxDropDownChoicePanel<TraceLevel> traceLevel = new AjaxDropDownChoicePanel<TraceLevel>("traceLevel",
                getString("traceLevel"), new PropertyModel(notificationTO, "traceLevel"));
        traceLevel.setChoices(Arrays.asList(TraceLevel.values()));
        traceLevel.addRequiredLabel();
        form.add(traceLevel);

        final UserSearchPanel about = new UserSearchPanel("about", notificationTO.getAbout());
        form.add(about);

        final AjaxDropDownChoicePanel<IntMappingType> recipientAttrType = new AjaxDropDownChoicePanel<IntMappingType>(
                "recipientAttrType",
                new ResourceModel("recipientAttrType", "recipientAttrType").getObject(),
                new PropertyModel<IntMappingType>(notificationTO, "recipientAttrType"));

        final Set<IntMappingType> toBeFiltered = new HashSet<IntMappingType>();
        toBeFiltered.add(IntMappingType.SyncopeUserId);
        toBeFiltered.add(IntMappingType.Password);

        recipientAttrType.setChoices(new ArrayList<IntMappingType>(
                (Set<IntMappingType>) IntMappingType.getAttributeTypes(AttributableType.USER, toBeFiltered)));

        recipientAttrType.setRequired(true);
        form.add(recipientAttrType);

        final AjaxDropDownChoicePanel<String> recipientAttrName = new AjaxDropDownChoicePanel<String>(
                "recipientAttrName",
                new ResourceModel("recipientAttrName", "recipientAttrName").getObject(),
                new PropertyModel(notificationTO, "recipientAttrName"));

        recipientAttrName.setChoices(getSchemaNames(notificationTO.getRecipientAttrType()));
        recipientAttrName.setRequired(true);
        form.add(recipientAttrName);

        recipientAttrType.getField().add(new AjaxFormComponentUpdatingBehavior(onchange) {

            @Override
            protected void onUpdate(final AjaxRequestTarget target) {
                recipientAttrName.setChoices(getSchemaNames(notificationTO.getRecipientAttrType()));
                target.add(recipientAttrName);
            }
        });

        final AjaxPalettePanel events = new AjaxPalettePanel("events", new PropertyModel(notificationTO, "events"),
                new ListModel<String>(restClient.getEvents()));
        form.add(events);

        final WebMarkupContainer recipientsContainer = new WebMarkupContainer("recipientsContainer");
        recipientsContainer.setOutputMarkupId(true);

        form.add(recipientsContainer);

        final AjaxCheckBoxPanel selfAsRecipient = new AjaxCheckBoxPanel("selfAsRecipient",
                getString("selfAsRecipient"), new PropertyModel(notificationTO, "selfAsRecipient"));
        form.add(selfAsRecipient);

        if (createFlag) {
            selfAsRecipient.getField().setDefaultModelObject(Boolean.TRUE);
        }

        final AjaxCheckBoxPanel checkRecipients =
                new AjaxCheckBoxPanel("checkRecipients", "checkRecipients",
                new Model(notificationTO.getRecipients() == null ? false : true));
        recipientsContainer.add(checkRecipients);

        final UserSearchPanel recipients =
                new UserSearchPanel("recipients",
                notificationTO.getRecipients() == null ? null : notificationTO.getRecipients());
        recipientsContainer.add(recipients);
        recipients.setEnabled(checkRecipients.getModelObject());

        selfAsRecipient.getField().add(new AjaxFormComponentUpdatingBehavior(onchange) {

            private static final long serialVersionUID = -1107858522700306810L;

            @Override
            protected void onUpdate(final AjaxRequestTarget target) {
                if (!Boolean.valueOf(selfAsRecipient.getField().getValue())) {
                    checkRecipients.getField().setDefaultModelObject(Boolean.TRUE);
                    target.add(checkRecipients);
                    recipients.setEnabled(checkRecipients.getModelObject());
                    target.add(recipients);
                    target.add(recipientsContainer);
                }
            }
        });

        checkRecipients.getField().add(new AjaxFormComponentUpdatingBehavior(onchange) {

            private static final long serialVersionUID = -1107858522700306810L;

            @Override
            protected void onUpdate(final AjaxRequestTarget target) {
                if (!checkRecipients.getModelObject()) {
                    selfAsRecipient.getField().setDefaultModelObject(Boolean.TRUE);
                    target.add(selfAsRecipient);
                }
                recipients.setEnabled(checkRecipients.getModelObject());
                target.add(recipients);
                target.add(recipientsContainer);
            }
        });

        AjaxButton submit = new IndicatingAjaxButton("apply", new Model<String>(getString("submit"))) {

            private static final long serialVersionUID = -958724007591692537L;

            @Override
            protected void onSubmit(final AjaxRequestTarget target, final Form form) {

                notificationTO.setAbout(about.buildSearchCond());
                notificationTO.setRecipients(checkRecipients.getModelObject() ? recipients.buildSearchCond() : null);
               
                try {
                    if (createFlag) {
                        restClient.createNotification(notificationTO);
                    } else {
                        restClient.updateNotification(notificationTO);
                    }
                    info(getString("operation_succeded"));

                    Configuration callerPage = (Configuration) callPageRef.getPage();
                    callerPage.setModalResult(true);

                    window.close(target);
                } catch (SyncopeClientCompositeErrorException scee) {
                    error(getString("error") + ":" + scee.getMessage());
                    target.add(feedbackPanel);
                }
            }

            @Override
            protected void onError(final AjaxRequestTarget target, final Form form) {

                target.add(feedbackPanel);
            }
        };

        String allowedRoles = createFlag
                ? xmlRolesReader.getAllAllowedRoles("Notification", "create")
                : xmlRolesReader.getAllAllowedRoles("Notification", "update");
        MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, allowedRoles);

        form.add(submit);

        add(form);
    }
View Full Code Here

                item.add(overridable);
                connectorTO.addConfiguration(property);
            }
        };

        final Form connectorForm = new Form("form");
        connectorForm.setModel(new CompoundPropertyModel(connectorTO));

        final Form connectorPropForm = new Form("connectorPropForm");
        connectorPropForm.setModel(new CompoundPropertyModel(connectorTO));
        connectorPropForm.setOutputMarkupId(true);

        propertiesContainer = new WebMarkupContainer("container");
        propertiesContainer.setOutputMarkupId(true);
        propertiesContainer.add(connectorPropForm);

        connectorForm.add(propertiesContainer);
        connectorPropForm.add(view);

        final AjaxLink check = new IndicatingAjaxLink("check", new ResourceModel("check")) {

            private static final long serialVersionUID = -7978723352517770644L;

            @Override
            public void onClick(final AjaxRequestTarget target) {
                connectorTO.setBundleName(bundleTO.getBundleName());
                connectorTO.setVersion(bundleTO.getVersion());

                if (restClient.check(connectorTO).booleanValue()) {
                    info(getString("success_connection"));
                } else {
                    error(getString("error_connection"));
                }

                target.add(feedbackPanel);
            }
        };

        connectorPropForm.add(check);

        final AjaxButton submit = new IndicatingAjaxButton("apply", new Model(getString("submit"))) {

            private static final long serialVersionUID = -958724007591692537L;
View Full Code Here

TOP

Related Classes of org.apache.wicket.markup.html.form.Form$FormValidatorRemovedChange

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.