@SuppressWarnings("unchecked")
  public static void prepareFormComponents(
      FormComponent formComponent,
      boolean isRequired,
      String label,
      int minimumLenght,
      int maximumLenght,
      boolean hasFeedBackPanel) {
    if (isRequired) {
      formComponent.setRequired(true);
    }
    if (!Strings.isEmpty(label)) {
      formComponent.setLabel(new Model<String>(label));
    }
    if (!(minimumLenght < 0)) {
      formComponent.add(StringValidator.minimumLength(minimumLenght));
    }
    if (!(maximumLenght < 0)) {
      formComponent.add(StringValidator.maximumLength(maximumLenght));
    }
    if (hasFeedBackPanel) {
      formComponent
          .getParent()
          .add(
              new FeedbackPanel(
                  formComponent.getId() + "FeedbackPanel",
                  new ComponentFeedbackMessageFilter(formComponent)));
    }

    // Add input behaviour
    formComponent.add(new ToUpperCaseBehaviour());
  }
  public RegisterHtmlForm(String id, RegisterForm registerForm) {
    super(id, new CompoundPropertyModel<RegisterForm>(registerForm));

    TextField<String> email =
        new RequiredTextField<String>(
            "register.email", new PropertyModel<String>(registerForm, "email"));
    add(email);
    email.add(EmailAddressValidator.getInstance());
    email.add(StringValidator.maximumLength(SimiConstants.VALID_EMAIL_MAX_LENGTH));

    PasswordTextField password =
        new PasswordTextField(
            "register.password", new PropertyModel<String>(registerForm, "password"));
    add(password);
    password.setRequired(true);
    password.add(
        StringValidator.lengthBetween(
            SimiConstants.VALID_PASSWORD_MIX_LENGTH, SimiConstants.VALID_PASSWORD_MAX_LENGTH));

    PasswordTextField repassword =
        new PasswordTextField(
            "register.repassword", new PropertyModel<String>(registerForm, "repassword"));
    add(repassword);
    repassword.setRequired(true);
    repassword.setResetPassword(false);
    repassword.add(
        StringValidator.lengthBetween(
            SimiConstants.VALID_PASSWORD_MIX_LENGTH, SimiConstants.VALID_PASSWORD_MAX_LENGTH));

    add(new EqualPasswordInputValidator(password, repassword));

    add(new FeedbackPanel(id + ".feedback", new ContainerFeedbackMessageFilter(this)));
  }
  @SuppressWarnings({"serial"})
  public CustomTaskPanel(String id, Task t) {
    super(id);
    task = t;

    add(new Label("taskid", task.getTaskId()));
    add(new Label("taskname", task.getName()));
    add(new Label("tasktype", task.getTaskType() != null ? task.getTaskType() : "N/A"));

    add(
        new Label(
            "taskdescription", task.getDescription() != null ? task.getDescription() : "N/A"));

    Form<Task> form = new Form<Task>("inputForm");
    form.setOutputMarkupId(true);

    form.add(new Label("taskid", new PropertyModel<String>(task, "taskId")));
    form.add(
        new TextField<String>("taskname", new PropertyModel<String>(task, "name"))
            .setRequired(true)
            .add(StringValidator.minimumLength(2)));
    form.add(
        new TextField<String>("tasktype", new PropertyModel<String>(task, "taskType"))
            .setRequired(true)
            .add(StringValidator.minimumLength(2)));
    form.add(
        new Label(
            "taskcreationTimestamp",
            task.getTaskCreationTimestamp() != null
                ? task.getTaskCreationTimestamp().toString()
                : "N/A"));
    form.add(
        new TextArea<String>("taskdescription", new PropertyModel<String>(task, "description"))
            .setRequired(true));

    form.add(
        new AjaxButton("submitButton", form) {
          @Override
          protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            try {
              service.finishTask(task);
              // setResponsePage(TaskOverviewPage.class);
            } catch (WorkflowException e) {
              e.printStackTrace();
            }
          }

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

    add(
        new ListView<String>("propertiesList", new ArrayList<String>(task.propertyKeySet())) {
          @Override
          protected void populateItem(ListItem<String> item) {
            item.add(new Label("propertiesLabel", item.getModel()));
          }
        });
  }
  public UserDtoEditor(String id, IModel<UserDto> model, Mode mode) {
    super(id, model);

    add(new FeedbackPanel("feedback", new ContainerFeedbackMessageFilter(this)));

    Form<?> form = new Form<Void>("form");
    add(form);

    FormComponent<?> login =
        new TextField<String>("login", new PropertyModel<String>(model, "login"))
            .setRequired(true)
            .add(StringValidator.lengthBetween(4, 32));
    login.setLabel(new Model<String>("Login"));
    login.setVisible(mode == Mode.CREATE || mode == Mode.EDIT);
    form.add(login);

    FormComponent<?> roles =
        new CheckBoxMultipleChoice<Role>(
            "roles",
            new PropertyModel<Collection<Role>>(model, "roles"),
            new RoleCollection(),
            new RoleRenderer());
    roles.setVisible(mode == Mode.CREATE || mode == Mode.EDIT);
    form.add(roles);

    FormComponent<?> password1 =
        new PasswordTextField("password1", new PropertyModel<String>(model, "password"))
            .setRequired(true)
            .add(StringValidator.lengthBetween(4, 32))
            .setLabel(new Model<String>("Password"));
    password1.setVisible(mode == Mode.CREATE || mode == Mode.CHANGE_PASSWORD);
    FormComponent<?> password2 = new PasswordTextField("password2", new Model<String>());
    password2.setLabel(new Model<String>("Confirm Password"));
    form.add(password1, password2);
    password2.setVisible(mode == Mode.CREATE || mode == Mode.CHANGE_PASSWORD);
    form.add(new EqualPasswordInputValidator(password1, password2));

    form.add(
        new Button("ok") {
          private static final long serialVersionUID = 1L;

          @Override
          public void onSubmit() {
            onOk(UserDtoEditor.this.getModelObject());
          }
        });

    form.add(
        new Link<Void>("cancel") {
          private static final long serialVersionUID = 1L;

          @Override
          public void onClick() {
            onCancel();
          }
        });
  }
Exemple #5
0
  public CustomerFormPanel(String id, CompoundPropertyModel<CustomerAdminBackingBean> model) {
    super(id, model);

    GreySquaredRoundedBorder greyBorder = new GreySquaredRoundedBorder("border");
    add(greyBorder);

    setOutputMarkupId(true);

    final Form<CustomerAdminBackingBean> form =
        new Form<CustomerAdminBackingBean>("customerForm", model);

    // name
    RequiredTextField<String> nameField = new RequiredTextField<String>("customer.name");
    form.add(nameField);

    nameField.add(StringValidator.lengthBetween(0, 64));
    nameField.setLabel(new ResourceModel("admin.customer.name"));
    nameField.add(new ValidatingFormComponentAjaxBehavior());
    form.add(new AjaxFormComponentFeedbackIndicator("nameValidationError", nameField));

    // code
    final RequiredTextField<String> codeField = new RequiredTextField<String>("customer.code");
    form.add(codeField);
    codeField.add(StringValidator.lengthBetween(0, 16));
    codeField.setLabel(new ResourceModel("admin.customer.code"));
    codeField.add(new ValidatingFormComponentAjaxBehavior());
    form.add(new UniqueCustomerValidator(nameField, codeField));
    form.add(new AjaxFormComponentFeedbackIndicator("codeValidationError", codeField));

    // description
    TextArea<String> textArea = new KeepAliveTextArea("customer.description");
    textArea.setLabel(new ResourceModel("admin.customer.description"));
    form.add(textArea);

    // active
    form.add(new CheckBox("customer.active"));

    // data save label
    form.add(new ServerMessageLabel("serverMessage", "formValidationError"));

    //

    boolean deletable = model.getObject().getCustomer().isDeletable();
    FormConfig formConfig =
        new FormConfig()
            .forForm(form)
            .withDelete(deletable)
            .withSubmitTarget(this)
            .withDeleteEventType(CustomerAjaxEventType.CUSTOMER_DELETED)
            .withSubmitEventType(CustomerAjaxEventType.CUSTOMER_UPDATED);

    FormUtil.setSubmitActions(formConfig);

    greyBorder.add(form);
  }
  public TaskPanel(String id, Task t) {
    super(id);
    task = t;

    // CompoundPropertyModel<Task> taskModel = new CompoundPropertyModel<Task>(task);
    Form<Task> form = new Form<Task>("inputForm");
    form.setOutputMarkupId(true);

    form.add(new Label("taskid", new PropertyModel<String>(task, "taskId")));
    form.add(
        new TextField<String>("taskname", new PropertyModel<String>(task, "name"))
            .setRequired(true)
            .add(StringValidator.minimumLength(2)));
    form.add(
        new TextField<String>("tasktype", new PropertyModel<String>(task, "taskType"))
            .setRequired(true)
            .add(StringValidator.minimumLength(2)));
    form.add(
        new Label(
            "taskcreationTimestamp",
            task.getTaskCreationTimestamp() != null
                ? task.getTaskCreationTimestamp().toString()
                : "N/A"));
    form.add(
        new TextArea<String>("taskdescription", new PropertyModel<String>(task, "description"))
            .setRequired(true));

    form.add(
        new AjaxSubmitLink("submitButton", form) {
          @Override
          protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            try {
              service.finishTask(task);
              target.add(TaskPanel.this.getParent());
            } catch (WorkflowException e) {
              LOGGER.error("Cant finish task", e);
            }
          }

          @Override
          protected void onError(AjaxRequestTarget target, Form<?> form) {}
        });
    add(form);
    add(
        new ListView<String>("propertiesList", new ArrayList<String>(task.propertyKeySet())) {
          @Override
          protected void populateItem(ListItem<String> item) {
            item.add(new Label("propertiesLabel", item.getModel()));
          }
        });
  }
    public CommentForm(String id, final Thread thread) {
      super(id);

      name = new TextArea("name", new PropertyModel(properties, "name"));
      name.setRequired(true);
      name.add(StringValidator.maximumLength(500));
      name.setLabel(new Model("Text"));
      add(name);
      add(new Label("nameLabel", "Text"));

      add(
          submit =
              new Button("submit", new ResourceModel("button.submit")) {

                public void onSubmit() {

                  Comment comment = new Comment();

                  comment.setName(name.getModelObjectAsString());
                  comment.setThread(thread);
                  comment.setOwner(user);

                  // not user input

                  comment.setActive(true);
                  comment.setState(true);

                  commentController.saveNewComment(comment);
                  name.setModelValue("");
                  setResponsePage(new CommentList(thread));
                  feedbackPanel.info("Vlo�en�");
                }
              });
    }
Exemple #8
0
    public CreateAccountForm(String id) {
      super(id);
      setModel(new Model<CreateAccountForm>(this));
      setMarkupId("createAccountForm");
      add(
          new TextField<String>(FIELD_USERNAME, new PropertyModel<String>(this, "username"))
              .setRequired(true)
              .add(StringValidator.lengthBetween(3, 32))
              .add(new PatternValidator("^\\w+$")));
      PasswordTextField pw =
          new PasswordTextField(FIELD_PASSWORD, new PropertyModel<String>(this, "password"));
      PasswordTextField pwc =
          new PasswordTextField(
              FIELD_PASSWORD_CONFIRM, new PropertyModel<String>(this, "password"));
      add(pw);
      add(pwc);
      add(new EqualPasswordInputValidator(pw, pwc));

      TextField<String> emailField =
          new TextField<String>(FIELD_EMAIL, new PropertyModel<String>(this, "email"));
      emailField.add(
          new IValidator<String>() {
            private static final long serialVersionUID = 1L;

            public void validate(IValidatable<String> validatable) {
              if (validatable.getValue() != null && !"".equals(validatable.getValue())) {
                EmailAddressValidator.getInstance().validate(validatable);
              }
            }
          });

      add(emailField);
      add(new TextField<String>(FIELD_CAPTCHA, new PropertyModel<String>(this, "captcha")));
      add(new FeedbackPanel("feedbackPanel"));
    }
Exemple #9
0
 /*
  * (non-Javadoc)
  *
  * @see au.org.theark.core.web.form.AbstractDetailForm#attachValidators()
  */
 @Override
 protected void attachValidators() {
   customFieldGroupTxtFld
       .setRequired(true)
       .setLabel(
           new StringResourceModel(
               "customFieldGroup.name", this, new Model<String>("Custom Field Group Name")));
   customFieldGroupTxtFld.add(StringValidator.maximumLength(1000));
 }
  private RequiredTextField<String> createLabelFieldWithValidation() {
    RequiredTextField<String> nameField = new RequiredTextField<String>("name");
    nameField.setLabel(new StringResourceModel("locationName", this, null));
    nameField.add(
        StringValidator.lengthBetween(MIN_LOCATION_NAME_LENGTH, MAX_LOCATION_NAME_LENGTH));

    nameField.add(createUniqueLocationNameValidator());

    return nameField;
  }
Exemple #11
0
 /*
  * (non-Javadoc)
  *
  * @see au.org.theark.core.web.form.AbstractDetailForm#attachValidators()
  */
 @Override
 protected void attachValidators() {
   areaCodeTxtFld.add(StringValidator.maximumLength(10));
   phoneTypeChoice
       .setRequired(true)
       .setLabel(
           (new StringResourceModel(
               "phone.phoneType.required", this, new Model<String>("Phone Type"))));
   phoneNumberTxtFld
       .setRequired(true)
       .setLabel(
           (new StringResourceModel(
               "phone.phoneNumber.required", this, new Model<String>("Phone Number"))));
   phoneStatusChoice
       .setRequired(true)
       .setLabel(
           (new StringResourceModel(
               "phone.phoneStatus.required", this, new Model<String>("Phone Status"))));
   phoneNumberTxtFld.add(StringValidator.maximumLength(20));
   dateReceivedDp
       .add(DateValidator.maximum(new Date()))
       .setLabel(new StringResourceModel("phone.dateReceived.DateValidator.maximum", this, null));
 }
  public ChangePasswordPanel() {
    txtOldPassword =
        new PasswordTextField("oldPassword", new PropertyModel<String>(this, "oldPassword"));
    txtOldPassword.setRequired(true);
    txtOldPassword.setLabel(Model.of("Parola veche"));
    addWithFeedback(txtOldPassword);

    txtNewPassword =
        new PasswordTextField("newPassword", new PropertyModel<String>(this, "newPassword"));
    txtNewPassword.setRequired(true);
    txtNewPassword.setLabel(Model.of("Parola noua"));
    txtNewPassword.add(StringValidator.minimumLength(6));
    addWithFeedback(txtNewPassword);

    txtRetypedPassword =
        new PasswordTextField(
            "retypedPassword", new PropertyModel<String>(this, "retypedPassword"));
    txtRetypedPassword.setRequired(true);
    txtRetypedPassword.setLabel(Model.of("Parola reintrodusa"));
    addWithFeedback(txtRetypedPassword);
  }
  protected void constructPanel() {

    final String chooseDtTxt = this.getLocalizer().getString("datepicker.chooseDate", mobBasePage);

    add(
        new HeaderContributor(
            new IHeaderContributor() {

              private static final long serialVersionUID = 1L;

              @Override
              public void renderHead(IHeaderResponse response) {

                // localize the jquery datepicker based on users locale setting
                // locale specific js includes for datepicker are available at
                // http://jquery-ui.googlecode.com/svn/trunk/ui/i18n/
                String localeLang = getLocale().getLanguage().toLowerCase();

                LOG.debug("Using DatePicker for locale language: {}", localeLang);

                if (PortalUtils.exists(localeLang)) {
                  response.renderJavascriptReference(
                      "scripts/jquery/i18n/jquery.ui.datepicker-" + localeLang + ".js");
                }

                response.renderJavascript(
                    "\n"
                        + "jQuery(document).ready(function($) { \n"
                        + "  $('#birthDate').datepicker( { \n"
                        + "	'buttonText' : '"
                        + chooseDtTxt
                        + "', \n"
                        + "	'changeMonth' : true, \n"
                        + "	'changeYear' : true, \n"
                        + "       'yearRange' : '-100:+0', \n"
                        + "	'showOn': 'both', \n"
                        + "	'dateFormat' : '"
                        + Constants.DATE_FORMAT_PATTERN_PICKER
                        + "', \n"
                        + "	'buttonImage': 'images/calendar.gif', \n"
                        + "	'buttonOnlyImage': true} ); \n"
                        + "});\n",
                    "datePicker");
              }
            }));

    final Form<?> form =
        new Form("standingDataForm", new CompoundPropertyModel<StandingDataPanel>(this));

    if (!PortalUtils.exists(getCustomer().getTaskId()))
      mobBasePage.getMobiliserWebSession().setShowContact(true);
    form.add(new FeedbackPanel("errorMessages"));
    form.add(
            new RequiredTextField<String>("customer.address.firstName")
                .setRequired(true)
                .add(new PatternValidator(Constants.REGEX_FIRSTNAME))
                .add(Constants.mediumStringValidator)
                .add(Constants.mediumSimpleAttributeModifier))
        .add(new ErrorIndicator());

    form.add(
        new DateTextField(
                "birthDateField",
                new PropertyModel<Date>(this, "customer.birthDateString"),
                new PatternDateConverter(Constants.DATE_FORMAT_PATTERN_PARSE, false))
            .setRequired(true)
            .add(new ErrorIndicator()));

    form.add(
        new LocalizableLookupDropDownChoice<Integer>(
                "customer.customerTypeId",
                Integer.class,
                Constants.RESOURCE_BUNDLE_CUSTOMER_TYPE,
                this,
                Boolean.FALSE,
                true)
            .setNullValid(false)
            .setRequired(true));

    form.add(
            new RequiredTextField<String>("customer.address.lastName")
                .setRequired(true)
                .add(new PatternValidator(Constants.REGEX_FIRSTNAME))
                .add(Constants.mediumStringValidator)
                .add(Constants.mediumSimpleAttributeModifier))
        .add(new ErrorIndicator());

    form.add(
        new LocalizableLookupDropDownChoice<String>(
                "customer.language",
                String.class,
                Constants.RESOURCE_BUNDLE_LANGUAGES,
                this,
                false,
                true)
            .add(new ErrorIndicator()));

    form.add(
        new LocalizableLookupDropDownChoice<String>(
                "customer.timeZone",
                String.class,
                Constants.RESOURCE_BUNDLE_TIMEZONES,
                this,
                false,
                true)
            .add(new ErrorIndicator()));

    form.add(
        new TextField<String>("customer.address.street1")
            .add(new PatternValidator(Constants.REGEX_STREET1))
            .add(Constants.mediumStringValidator)
            .add(Constants.mediumSimpleAttributeModifier)
            .add(new ErrorIndicator()));

    form.add(
        new TextField<String>("customer.address.houseNo")
            .add(StringValidator.lengthBetween(1, 20))
            .add(Constants.mediumStringValidator)
            .add(Constants.mediumSimpleAttributeModifier)
            .add(new ErrorIndicator()));
    form.add(
        new TextField<String>("customer.address.state")
            .add(new PatternValidator(Constants.REGEX_STATE))
            .add(Constants.mediumStringValidator)
            .add(Constants.mediumSimpleAttributeModifier)
            .add(new ErrorIndicator()));

    form.add(
        new LocalizableLookupDropDownChoice<String>(
                "customer.address.kvCountry", String.class, "countries", this, false, true)
            .setNullValid(false)
            .setRequired(true)
            .add(new ErrorIndicator()));

    form.add(
        new TextField<String>("customer.address.street2")
            .add(new PatternValidator(Constants.REGEX_STREET1))
            .add(Constants.mediumStringValidator)
            .add(Constants.mediumSimpleAttributeModifier)
            .add(new ErrorIndicator()));

    form.add(
        new TextField<String>("customer.address.city")
            .setRequired(false)
            .add(new PatternValidator(Constants.REGEX_CITY))
            .add(Constants.mediumStringValidator)
            .add(Constants.mediumSimpleAttributeModifier)
            .add(new ErrorIndicator()));

    form.add(
        new TextField<String>("customer.address.zip")
            .add(new PatternValidator(Constants.REGEX_ZIP))
            .add(Constants.mediumStringValidator)
            .add(Constants.mediumSimpleAttributeModifier)
            .add(new ErrorIndicator()));

    TextField<String> msisdn = new TextField<String>("customer.msisdn");
    if (!mobBasePage.getConfiguration().isMsisdnOtpConfirmed()) {
      msisdn.add(new SimpleAttributeModifier("readonly", "readonly"));
      msisdn.add(new SimpleAttributeModifier("style", "background-color: #E6E6E6;"));
    }
    form.add(
        msisdn
            .add(new PatternValidator(Constants.REGEX_PHONE_NUMBER))
            .add(Constants.mediumStringValidator)
            .add(Constants.mediumSimpleAttributeModifier)
            .add(new ErrorIndicator()));

    form.add(
        new TextField<String>("customer.address.email")
            .setRequired(true)
            .add(EmailAddressValidator.getInstance())
            .add(Constants.mediumStringValidator)
            .add(Constants.mediumSimpleAttributeModifier)
            .add(new ErrorIndicator()));

    form.add(
        new LocalizableLookupDropDownChoice<Integer>(
                "customer.kvInfoMode", Integer.class, "sendModes", this, Boolean.FALSE, true)
            .setNullValid(false)
            .setRequired(true));

    WebMarkupContainer networkProviderDiv = new WebMarkupContainer("networkProviderDiv");

    networkProviderDiv.add(
        new LocalizableLookupDropDownChoice<String>(
                "customer.networkProvider", String.class, "networkproviders", this, false, true)
            .setNullValid(false)
            .setRequired(true)
            .add(new ErrorIndicator()));

    // network provider selection to be made only for mbanking customer
    // types
    if (customer.getCustomerTypeId() != null
        && customer.getCustomerTypeId().intValue() == Constants.MBANKING_CUSTOMER_TYPE) {
      networkProviderDiv.setVisible(true);
    } else {
      networkProviderDiv.setVisible(false);
    }

    form.add(networkProviderDiv);

    form.add(
        new KeyValueDropDownChoice<Long, String>(
            "customer.feeSetId", mobBasePage.getFeeSets(getCustomer().getFeeSetId())) {
          private static final long serialVersionUID = 1L;

          @Override
          protected CharSequence getDefaultChoice(Object selected) {
            return null;
          };
        }.setNullValid(false));

    form.add(
        new KeyValueDropDownChoice<Long, String>(
            "customer.limitId", getLimitSets(getCustomer().getLimitId())) {

          private static final long serialVersionUID = 1L;
        }.setNullValid(true));

    Button feeSetConfButton =
        new Button("feeSetConf") {
          private static final long serialVersionUID = 1L;

          @Override
          public void onSubmit() {
            setResponsePage(new IndividualFeeSetConfig(getCustomer()));
          };
        }.setDefaultFormProcessing(false);
    feeSetConfButton.add(new PrivilegedBehavior(mobBasePage, Constants.PRIV_CUST_WRITE));
    form.add(feeSetConfButton);

    Button limitSetConfButton =
        new Button("limitSetConf") {
          private static final long serialVersionUID = 1L;

          @Override
          public void onSubmit() {
            setResponsePage(new IndividualLimitSetConfig(getCustomer()));
          };
        }.setDefaultFormProcessing(false);
    limitSetConfButton.add(new PrivilegedBehavior(mobBasePage, Constants.PRIV_CUST_WRITE));
    form.add(limitSetConfButton);

    form.add(
        new LocalizableLookupDropDownChoice<String>(
                "customer.securityQuestion",
                String.class,
                Constants.RESOURCE_BUNDLE_SEC_QUESTIONS,
                this,
                false,
                true)
            .setNullValid(false)
            .setRequired(true)
            .add(new ErrorIndicator()));

    form.add(
        new TextField<String>("customer.userName")
            .add(new PatternValidator(Constants.REGEX_USERNAME))
            .add(Constants.mediumStringValidator)
            .add(Constants.mediumSimpleAttributeModifier)
            .add(new ErrorIndicator()));

    form.add(
        new RequiredTextField<String>("customer.SecQuesAns")
            .add(new PatternValidator(Constants.REGEX_SECURITY_ANSWER))
            .add(Constants.mediumStringValidator)
            .add(Constants.mediumSimpleAttributeModifier)
            .add(new ErrorIndicator()));

    PrivilegedBehavior cancelReasonBehavior =
        new PrivilegedBehavior(mobBasePage, Constants.PRIV_CUST_CANCEL);
    cancelReasonBehavior.setMissingPrivilegeHidesComponent(false);
    KeyValueDropDownChoice<Integer, String> custStatus =
        new KeyValueDropDownChoice<Integer, String>(
            "customer.active", mobBasePage.getCustomerStatus());
    custStatus.add(
        new SimpleAttributeModifier(
            "onchange",
            "confirmDeactivation('"
                + getLocalizer().getString("customer.deactivate.warning", mobBasePage)
                + "')"));
    form.add(custStatus.setNullValid(false).setRequired(true).add(cancelReasonBehavior));

    WebMarkupContainer blackListReasonDiv = new WebMarkupContainer("blackListReasonDiv");
    PrivilegedBehavior blackListBehavior =
        new PrivilegedBehavior(mobBasePage, Constants.PRIV_CUST_BLACKLIST);
    blackListBehavior.setMissingPrivilegeHidesComponent(false);
    blackListReasonDiv.add(
        new LocalizableLookupDropDownChoice<Integer>(
                "customer.blackListReason",
                Integer.class,
                "blackListReasons",
                this,
                Boolean.FALSE,
                true)
            .setNullValid(false)
            .setRequired(true)
            .add(blackListBehavior));

    form.add(blackListReasonDiv);

    WebMarkupContainer cancelDivContainer = new WebMarkupContainer("cancelDivContainer");
    LocalizableLookupDropDownChoice<Integer> cancelationreason =
        new LocalizableLookupDropDownChoice<Integer>(
            "customer.cancelationReason", Integer.class, "cancellationReasons", this, false, true);
    cancelationreason.add(
        new SimpleAttributeModifier(
            "onchange",
            "confirmCancellation('"
                + getLocalizer().getString("customer.cancel.warning", mobBasePage)
                + "')"));
    cancelDivContainer.add(
        cancelationreason.setNullValid(false).setRequired(true).add(cancelReasonBehavior));
    // cancelDivContainer
    // .setVisible(getCustomer().getCustomerTypeId() ==
    // Constants.CONSUMER_IDTYPE
    // || getCustomer().getCustomerTypeId() ==
    // Constants.CUSTOMER_ROLE_MONEY_MERCHANT);
    form.add(cancelDivContainer);
    Button changenMsisdnButton =
        new Button("changeMsisdn") {
          private static final long serialVersionUID = 1L;

          @Override
          public void onSubmit() {
            Customer customer =
                mobBasePage.getCustomerByIdentification(
                    Constants.IDENT_TYPE_CUST_ID, String.valueOf(getCustomer().getId()));
            if (customer.getCancellationReasonId() != 0 || !customer.isActive()) {
              error(
                  getLocalizer()
                      .getString("customer.msisdn.change.error.customerinactive", mobBasePage));
              return;
            }
            mobBasePage.getMobiliserWebSession().setCustomerOtp(null);
            mobBasePage.getMobiliserWebSession().setCustomerOtpCount(0);
            mobBasePage.getMobiliserWebSession().setCustomerOtpLimitHit(false);
            setResponsePage(new ChangeMsisdnPage(getCustomer()));
          };
        }.setDefaultFormProcessing(false);
    changenMsisdnButton.setVisible(!mobBasePage.getConfiguration().isMsisdnOtpConfirmed());
    changenMsisdnButton.add(new PrivilegedBehavior(mobBasePage, Constants.PRIV_CUST_WRITE));

    form.add(changenMsisdnButton);
    changenMsisdnButton.setVisible(!mobBasePage.getConfiguration().isMsisdnOtpConfirmed());

    form.add(
        new Button("resetPin") {
          private static final long serialVersionUID = 1L;

          @Override
          public void onSubmit() {
            Customer customer =
                mobBasePage.getCustomerByIdentification(
                    Constants.IDENT_TYPE_MSISDN, getCustomer().getMsisdn());
            if (!PortalUtils.exists(customer)) {
              error(getLocalizer().getString("customer.reset.password.noMsisdn", mobBasePage));
              return;
            }
            setResponsePage(new ResetCredentialPage(getCustomer(), this.getWebPage(), "pin"));
          };
        }.setDefaultFormProcessing(false)
            .add(new PrivilegedBehavior(mobBasePage, Constants.PRIV_CUST_PINCALL)));

    form.add(
        new Button("resetPassword") {
          private static final long serialVersionUID = 1L;

          @Override
          public void onSubmit() {
            Address address = mobBasePage.getAddressByCustomer(getCustomer().getId());
            if (address == null || !PortalUtils.exists(address.getEmail())) {
              error(getLocalizer().getString("customer.reset.password.noEmail", mobBasePage));
              return;
            }
            setResponsePage(new ResetCredentialPage(getCustomer(), this.getWebPage(), "password"));
          };
        }.setDefaultFormProcessing(false)
            .add(new PrivilegedBehavior(mobBasePage, Constants.PRIV_CUST_PASSWORD)));

    form.add(
        new Button("update") {
          private static final long serialVersionUID = 1L;

          @Override
          public void onSubmit() {
            if (updateCustomer()) {
              LOG.info(
                  "Data updated successfully for customer["
                      + mobBasePage.getMobiliserWebSession().getCustomer().getId()
                      + "]");
              getSession().info(getLocalizer().getString("data.update.successful", mobBasePage));
              setResponsePage(new StandingDataPage(getCustomer()));
            }
          };
        }.add(new PrivilegedBehavior(mobBasePage, Constants.PRIV_CUST_WRITE))
            .setVisible(!PortalUtils.exists(getCustomer().getTaskId())));

    form.add(
        new Button("approve") {
          private static final long serialVersionUID = 1L;

          @Override
          public void onSubmit() {
            approveCustomer(true);
          };
        }.setDefaultFormProcessing(false)
            .setVisible(PortalUtils.exists(getCustomer().getTaskId())));

    form.add(
        new Button("reject") {
          private static final long serialVersionUID = 1L;

          @Override
          public void onSubmit() {
            approveCustomer(false);
          };
        }.setDefaultFormProcessing(false)
            .setVisible(PortalUtils.exists(getCustomer().getTaskId())));

    if (PortalUtils.exists(getCustomer().getTaskId())) {
      Iterator iter = form.iterator();
      Component component;
      for (int i = 0; iter.hasNext(); i++) {
        component = (Component) iter.next();

        if (component.getId().equals("approve")
            || component.getId().equals("reject")
            || component instanceof FeedbackPanel) {
          continue;
        } else if (component instanceof Button) {
          component.setVisible(false);
        } else {

          if (component.getId().equals("blackListReasonDiv")
              || component.getId().equals("cancelDivContainer")) {
            Iterator iter1 = ((WebMarkupContainer) component).iterator();
            Component comp;
            for (int j = 0; iter1.hasNext(); j++) {
              comp = (Component) iter1.next();
              comp.setEnabled(false);
              comp.add(new SimpleAttributeModifier("readonly", "readonly"));
              comp.add(new SimpleAttributeModifier("style", "background-color: #E6E6E6;"));
            }

          } else {
            component.setEnabled(false);
            component.add(new SimpleAttributeModifier("readonly", "readonly"));
            component.add(new SimpleAttributeModifier("style", "background-color: #E6E6E6;"));
          }
        }
      }
    }

    add(form);

    LOG.debug(
        "PatternDateConverter format: "
            + Constants.DATE_FORMAT_PATTERN_PARSE
            + " DatePicker format: "
            + Constants.DATE_FORMAT_PATTERN_PICKER);
  }
  @Override
  protected void onInitialize() {
    super.onInitialize();
    add(new FeedbackPanel("feedback"));

    final Administrator newAdmin = new Administrator();
    newAdmin.setAccessLevel("passenger");

    Form<TripList> form = new Form<>("administrator-registration-form");
    add(form);
    TextField<String> loginField =
        new TextField<String>("login", new PropertyModel<String>(newAdmin, "login"));
    loginField.setRequired(true);
    loginField.add(StringValidator.maximumLength(50));
    form.add(loginField);

    // можно добавить второе поле для проверки корректности ввода
    PasswordTextField passwordField =
        new PasswordTextField("password", new PropertyModel<String>(newAdmin, "password"));
    passwordField.setRequired(true);
    passwordField.add(StringValidator.maximumLength(50));
    form.add(passwordField);

    TextField<String> firstNameField =
        new TextField<String>("first-name", new PropertyModel<String>(newAdmin, "firstName"));
    firstNameField.setRequired(true);
    firstNameField.add(StringValidator.maximumLength(50));
    form.add(firstNameField);

    TextField<String> lastNameField =
        new TextField<String>("last-name", new PropertyModel<String>(newAdmin, "lastName"));
    lastNameField.setRequired(true);
    lastNameField.add(StringValidator.maximumLength(50));
    form.add(lastNameField);

    TextField<String> emailField =
        new TextField<String>("email", new PropertyModel<String>(newAdmin, "email"));
    emailField.setRequired(true);
    emailField.add(StringValidator.maximumLength(50));
    form.add(emailField);

    form.add(
        new SubmitLink("submit-button") {
          @Override
          public void onSubmit() {

            // TODO - correct
            //				if (aService.getByLogin(newAdmin.getLogin()) != null) {
            //					warn("such login already exists");
            //				}
            //				if (aService.getByLogin(newAdmin.getLogin()) != null) {
            //					warn("user with such email already exists");
            //				}
            //
            //				if (aService.getByLogin(newAdmin.getLogin()) == null
            //						&& aService.getByLogin(newAdmin.getLogin()) == null) {
            aService.register(newAdmin);
            setResponsePage(new HomePage());
            // }
          }
        });
  }
  public SendNewPasswordPage(Long pupilId) {
    super(UserLevel.TEACHER, true);

    if (pupilId == null) {
      throw new IllegalArgumentException("Must provide a valid pupilId"); // $NON-NLS-1$
    }

    final PupilModel pupilModel = new PupilModel(pupilId);

    // Find intro message from teachers attributes
    WelcomeIntroductionTeacherAttribute welcomeIntroduction =
        TeachUsSession.get().getTeacherAttribute(WelcomeIntroductionTeacherAttribute.class);
    if (welcomeIntroduction != null) {
      setIntroMessage(welcomeIntroduction.getValue());
    }

    String title = TeachUsSession.get().getString("SendNewPasswordPage.title"); // $NON-NLS-1$
    title = title.replace("{pupilname}", pupilModel.getObject().getName()); // $NON-NLS-1$
    add(new Label("newPasswordTitle", title)); // $NON-NLS-1$

    FormPanel formPanel = new FormPanel("passwordForm"); // $NON-NLS-1$
    add(formPanel);

    // Password 1
    final PasswordFieldElement password1Field =
        new PasswordFieldElement(
            TeachUsSession.get().getString("General.password"),
            new PropertyModel(this, "password1"),
            true); //$NON-NLS-1$ //$NON-NLS-2$
    password1Field.add(StringValidator.lengthBetween(4, 32));
    formPanel.addElement(password1Field);

    // Password 2
    final PasswordFieldElement password2Field =
        new PasswordFieldElement(
            TeachUsSession.get().getString("PersonPanel.repeatPassword"),
            new PropertyModel(this, "password2"),
            true); //$NON-NLS-1$ //$NON-NLS-2$
    formPanel.addElement(password2Field);

    // Password validator
    formPanel.addValidator(
        new FormValidator() {
          private static final long serialVersionUID = 1L;

          public IFormValidator getFormValidator() {
            return new EqualInputValidator(
                password1Field.getFormComponent(), password2Field.getFormComponent());
          }
        });

    // Password generator
    formPanel.addElement(
        new GeneratePasswordElement("", pupilModel.getObject().getUsername()) { // $NON-NLS-1$
          private static final long serialVersionUID = 1L;

          @Override
          protected void passwordGenerated(AjaxRequestTarget target, String password) {
            setPassword1(password);
            setPassword2(password);

            target.addComponent(password1Field.getFormComponent());
            target.addComponent(password1Field.getFeedbackPanel());
            target.addComponent(password2Field.getFormComponent());
            target.addComponent(password2Field.getFeedbackPanel());
          }
        });

    // Text
    formPanel.addElement(
        new TextAreaElement(
            TeachUsSession.get().getString("SendNewPasswordPage.introMessage"),
            new PropertyModel(this, "introMessage"))); // $NON-NLS-1$ //$NON-NLS-2$

    // Buttons
    formPanel.addElement(
        new ButtonPanelElement(TeachUsSession.get().getString("General.send")) { // $NON-NLS-1$
          private static final long serialVersionUID = 1L;

          @Override
          protected void onCancel() {
            getRequestCycle().setResponsePage(PupilsPage.class);
          }

          @Override
          protected void onSave(AjaxRequestTarget target) {
            PersonDAO personDAO = TeachUsApplication.get().getPersonDAO();
            MessageDAO messageDAO = TeachUsApplication.get().getMessageDAO();

            // Update pupil
            final Pupil pupil = pupilModel.getObject();
            pupil.setPassword(getPassword1());
            personDAO.save(pupil);

            // Create mail message
            Message message = new MailMessage();
            message.setSender(pupil.getTeacher());
            message.setRecipient(pupil);
            message.setState(MessageState.FINAL);

            String subject =
                TeachUsSession.get().getString("NewPasswordMail.subject"); // $NON-NLS-1$
            message.setSubject(subject);

            String body = TeachUsSession.get().getString("NewPasswordMail.body"); // $NON-NLS-1$
            body = body.replace("${username}", pupil.getUsername()); // $NON-NLS-1$
            body = body.replace("${password}", getPassword1()); // $NON-NLS-1$
            String serverUrl = TeachUsApplication.get().getServerUrl();
            body = body.replace("${server}", serverUrl); // $NON-NLS-1$
            String im = getIntroMessage();
            if (Strings.isEmpty(im) == false) {
              im += "\n\n"; // $NON-NLS-1$
            }
            body = body.replace("${introMessage}", im); // $NON-NLS-1$
            message.setBody(body);

            messageDAO.save(message);

            getRequestCycle().setResponsePage(PupilsPage.class);
          }
        });
  }
 private void initComponent() {
   add(StringValidator.minimumLength(MINIMUM_INPUT_LENGTH));
 }