Esempio n. 1
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"));
  }
Esempio n. 2
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);
  }