@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); }
private void createActiveInput(Form<T> form) { CheckBox activeCheckbox = new CheckBox("user.active"); activeCheckbox.setMarkupId("active"); form.add(activeCheckbox); }