예제 #1
0
 private void createMailInput(Form<T> form) {
   TextField<String> emailField = new TextField<String>("user.email");
   emailField.add(EmailAddressValidator.getInstance());
   emailField.add(new ValidatingFormComponentAjaxBehavior());
   form.add(emailField);
   form.add(new AjaxFormComponentFeedbackIndicator("emailValidationError", emailField));
 }
예제 #2
0
 private void createUsernameInput(Form<T> form) {
   RequiredTextField<String> usernameField = new RequiredTextField<String>("user.username");
   form.add(usernameField);
   usernameField.add(new StringValidator(0, 32));
   usernameField.add(new DuplicateUsernameValidator());
   usernameField.setLabel(new ResourceModel("admin.user.username"));
   usernameField.add(new ValidatingFormComponentAjaxBehavior());
   form.add(new AjaxFormComponentFeedbackIndicator("userValidationError", usernameField));
 }
예제 #3
0
  private void createNameInput(Form<T> form) {
    TextField<String> firstNameField = new TextField<String>("user.firstName");
    form.add(firstNameField);

    TextField<String> lastNameField = new RequiredTextField<String>("user.lastName");
    form.add(lastNameField);
    lastNameField.setLabel(new ResourceModel("admin.user.lastName"));
    lastNameField.add(new ValidatingFormComponentAjaxBehavior());
    form.add(new AjaxFormComponentFeedbackIndicator("lastNameValidationError", lastNameField));
  }
예제 #4
0
 private void createRoleInput(Form<T> form) {
   ListMultipleChoice<UserRole> userRoles =
       new ListMultipleChoice<UserRole>("user.userRoles", getUserRoles(), new UserRoleRenderer());
   userRoles.setMaxRows(4);
   userRoles.setLabel(new ResourceModel("admin.user.roles"));
   userRoles.setRequired(true);
   userRoles.add(new ValidatingFormComponentAjaxBehavior());
   form.add(userRoles);
   form.add(new AjaxFormComponentFeedbackIndicator("rolesValidationError", userRoles));
 }
예제 #5
0
  @Override
  protected void onInitialize() {
    super.onInitialize();

    IModel<T> userModel = getPanelModel();

    T manageUserBackingBean = getPanelModelObject();
    User user = manageUserBackingBean.getUser();

    boolean editMode = user.getPK() != null;

    GreySquaredRoundedBorder greyBorder = new GreySquaredRoundedBorder(BORDER, WebGeo.AUTO);
    add(greyBorder);

    setOutputMarkupId(true);

    final Form<T> form = new Form<T>(FORM, userModel);

    createUsernameInput(form);
    createNameInput(form);
    createMailInput(form);
    createPasswordInput(userModel, manageUserBackingBean, form);
    createDepartmentInput(form);
    createRoleInput(form);
    createActiveInput(form);

    // show assignments
    CheckBox showAssignments = new CheckBox("showAssignments");
    showAssignments.setMarkupId("showAssignments");
    showAssignments.setVisible(!manageUserBackingBean.isEditMode());
    form.add(showAssignments);

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

    boolean deletable = user.isDeletable();

    FormConfig formConfig =
        FormConfig.forForm(form)
            .withDelete(deletable)
            .withDeleteEventType(USER_DELETED)
            .withSubmitTarget(this)
            .withSubmitEventType(editMode ? USER_UPDATED : USER_CREATED);

    FormUtil.setSubmitActions(formConfig);

    greyBorder.add(form);

    onFormCreated(form);
  }
예제 #6
0
  private void createPasswordInput(IModel<T> userModel, T manageUserBackingBean, Form<T> form) {
    Label label = new Label("passwordEditLabel", new ResourceModel("admin.user.editPassword"));
    label.setVisible(manageUserBackingBean.isEditMode());
    form.add(label);

    PasswordFieldFactory.createOptionalPasswordFields(
        form, new PropertyModel<String>(userModel, "user.password"));
  }
예제 #7
0
  protected void createDepartmentInput(Form<T> form) {
    Fragment f = new Fragment("dept", "department", this);

    DropDownChoice<UserDepartment> userDepartment =
        new DropDownChoice<UserDepartment>(
            "user.userDepartment",
            getUserDepartments(),
            new ChoiceRenderer<UserDepartment>("name"));
    userDepartment.setRequired(true);
    userDepartment.setLabel(new ResourceModel("admin.user.department"));
    userDepartment.add(new ValidatingFormComponentAjaxBehavior());
    f.add(userDepartment);
    f.add(new AjaxFormComponentFeedbackIndicator("departmentValidationError", userDepartment));
    form.add(f);
  }
예제 #8
0
 private void createActiveInput(Form<T> form) {
   CheckBox activeCheckbox = new CheckBox("user.active");
   activeCheckbox.setMarkupId("active");
   form.add(activeCheckbox);
 }