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

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


  private static class TestPage extends WebPage implements IMarkupResourceStreamProvider
  {
    public TestPage(final ListModel<FileUpload> model)
    {
      Form f = new Form("f")
      {
        @Override
        protected void onSubmit()
        {
          super.onSubmit();

          TestPage.this.onSubmit();
        }
      };
      add(f);

      f.add(new MultiFileUploadField("muf", model));
    }
View Full Code Here


        });

    setDefaultModel(parentModel); // so we don't need to get it from the
                    // form.

    Form parentForm = new Form("parentForm", parentModel)
    {
      @Override
      protected void onValidateModelObjects()
      {
        super.onValidateModelObjects();

        ((ParentModel)getModelObject()).setParentValidated(true);
      }
    };
    parentForm.add(new TextField("name"));
    parentForm.add(new TextField("company"));
    add(parentForm);

    IModel<ChildModel> childModel = new CompoundPropertyModel(parentModel);
    parentForm.add(new AddressFormPanel("addressInfo", (IModel<ChildModel>)childModel));

    parentForm.add(new AjaxSubmitLink("parentSubmitBtn", parentForm)
    {
      @Override
      protected void onSubmit(AjaxRequestTarget target, Form<?> form)
      {
        super.onSubmit(target, form);
View Full Code Here

  }

  private void setupPanel()
  {
    // create the form and add the fields and submit button
    Form form = new Form("childForm", getDefaultModel())
    {
      @Override
      protected void onValidateModelObjects()
      {
        super.onValidateModelObjects();
        ((ChildModel)getModelObject()).setChildValidated(true);
      }
    };

    add(form);

    // add all the form fields
    form.add(new TextField("address1"));
    form.add(new TextField("address2"));
    form.add(new TextField("city"));
    form.add(new TextField("state"));
    form.add(new TextField("zip"));

    // add the child submit button
    add(new AjaxSubmitLink("childSubmitButton", form)
    {
      @Override
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<String>(notificationTO, "template"));
        template.setChoices(restClient.getMailTemplates());
        template.addRequiredLabel();
        form.add(template);

        final AjaxDropDownChoicePanel<TraceLevel> traceLevel = new AjaxDropDownChoicePanel<TraceLevel>(
                "traceLevel", getString("traceLevel"),
                new PropertyModel<TraceLevel>(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"));
        recipientAttrType.setChoices(new ArrayList<IntMappingType>(
                IntMappingType.getAttributeTypes(AttributableType.USER,
                EnumSet.of(IntMappingType.UserId, IntMappingType.Password))));
        recipientAttrType.setRequired(true);
        form.add(recipientAttrType);

        final AjaxDropDownChoicePanel<String> recipientAttrName = new AjaxDropDownChoicePanel<String>(
                "recipientAttrName", new ResourceModel("recipientAttrName", "recipientAttrName").getObject(),
                new PropertyModel<String>(notificationTO, "recipientAttrName"));
        recipientAttrName.setChoices(getSchemaNames(recipientAttrType.getModelObject()));
        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(recipientAttrType.getModelObject()));
                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

                createLink, ENABLE, xmlRolesReader.getAllAllowedRoles("Users", "create"));
        add(createLink);

        setWindowClosedReloadCallback(editModalWin);

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

        final UserSearchPanel searchPanel = new UserSearchPanel("searchPanel");
        searchForm.add(searchPanel);

        final ClearIndicatingAjaxButton searchButton =
                new ClearIndicatingAjaxButton("search", new ResourceModel("search"), getPageReference()) {

            private static final long serialVersionUID = -958724007591692537L;

            @Override
            protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) {
                final NodeCond searchCond = searchPanel.buildSearchCond();
                LOG.debug("Node condition " + searchCond);

                doSearch(target, searchCond, searchResult);

                Session.get().getFeedbackMessages().clear();
                target.add(searchPanel.getSearchFeedback());
            }

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

                target.add(searchPanel.getSearchFeedback());
            }
        };

        searchForm.add(searchButton);
        searchForm.setDefaultButton(searchButton);
    }
View Full Code Here

        fragment.add(new Label("new", userTO.getId() == 0
                ? new ResourceModel("new")
                : new Model("")));

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

        //--------------------------------
        // User details
        //--------------------------------
        form.add(new UserDetailsPanel("details", userTO, form, resetPassword, mode == Mode.TEMPLATE));

        form.add(new Label("statuspanel", ""));

        form.add(new Label("pwdChangeInfo", ""));

        form.add(new Label("accountinformation", ""));
        //--------------------------------

        //--------------------------------
        // Attributes panel
        //--------------------------------
        form.add(new AttributesPanel("attributes", userTO, form, mode == Mode.TEMPLATE));
        //--------------------------------

        //--------------------------------
        // Derived attributes panel
        //--------------------------------
        form.add(new DerivedAttributesPanel("derivedAttributes", userTO));
        //--------------------------------

        //--------------------------------
        // Virtual attributes panel
        //--------------------------------
        form.add(new VirtualAttributesPanel("virtualAttributes", userTO, mode == Mode.TEMPLATE));
        //--------------------------------

        //--------------------------------
        // Resources panel
        //--------------------------------
        form.add(new ResourcesPanel.ResourcesPanelBuilder("resources")
                .attributableTO(userTO).statusPanel(null).build());
        //--------------------------------

        //--------------------------------
        // Roles panel
        //--------------------------------
        form.add(new MembershipsPanel("memberships", userTO, mode == Mode.TEMPLATE, null, getPageReference()));
        //--------------------------------

        final AjaxButton submit = getOnSubmit();

        if (mode == Mode.ADMIN) {
            String allowedRoles = userTO.getId() == 0
                    ? xmlRolesReader.getAllAllowedRoles("Users", "create")
                    : xmlRolesReader.getAllAllowedRoles("Users", "update");
            MetaDataRoleAuthorizationStrategy.authorize(submit, RENDER, allowedRoles);
        }

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

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

            private static final long serialVersionUID = 530608535790823587L;

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

        return form;
    }
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() == null || 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() == null || 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

    public TextField<String> name;
    public Form form;

    public TestPage()
    {
      form = new Form("form");
      add(form);
      name = new TextField<String>("name", Model.of(""));
      form.add(name);
    }
View Full Code Here

        new PropertyEditableColumn(new ColumnLocation(Alignment.RIGHT, 8, Unit.EM), "R1",
            "userObject.property6"),

    };

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

    tree = new TreeTable("treeTable", createTreeModel(), columns);
    form.add(tree);
    tree.getTreeState().collapseAll();
  }
View Full Code Here

    public RoleTabPanel(final String id, final RoleTO roleTO, final ModalWindow window,
            final PageReference pageRef) {

        super(id);

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

        final TreeActionLinkPanel actionLink = new TreeActionLinkPanel("actionLink", roleTO.getId(),
                new CompoundPropertyModel(roleTO), window, pageRef);

        this.add(actionLink);
        this.add(new Label("displayName", roleTO.getDisplayName()));

        form.setModel(new CompoundPropertyModel(roleTO));
        form.setOutputMarkupId(true);

        final RolePanel rolePanel = new RolePanel("rolePanel", form, roleTO, RoleModalPage.Mode.ADMIN);
        rolePanel.setEnabled(false);
        form.add(rolePanel);

        final WebMarkupContainer userListContainer = new WebMarkupContainer("userListContainer");

        userListContainer.setOutputMarkupId(true);
        userListContainer.setEnabled(true);
        userListContainer.add(new UserSearchResultPanel("userList", true, null, pageRef, restClient));
        userListContainer.add(new ClearIndicatingAjaxButton("search", new ResourceModel("search"), pageRef) {

            private static final long serialVersionUID = -958724007591692537L;

            @Override
            protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) {
                final MembershipCond membershipCond = new MembershipCond();
                membershipCond.setRoleName(roleTO.getName());
                NodeCond cond = NodeCond.getLeafCond(membershipCond);

                userListContainer.replace(new UserSearchResultPanel("userList", true, cond, pageRef, restClient));

                target.add(userListContainer);
            }
        });

        form.add(userListContainer);
        add(form);
    }
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.