DataSourceField idDataField = new DataSourceIntegerField(Field.ID, "ID");
idDataField.setPrimaryKey(true);
idDataField.setCanEdit(false);
fields.add(idDataField);
DataSourceTextField usernameField = createTextField(Field.NAME, MSG.common_title_username(), 3, 100, true);
// Don't allow characters that could be used in HTML intended for an XSS attack.
RegExpValidator regExpValidator = new RegExpValidator("[^&<]*");
usernameField.setValidators(regExpValidator);
fields.add(usernameField);
DataSourceTextField ldapField = createBooleanField(Field.LDAP, MSG.dataSource_users_field_ldap(), true);
ldapField.setCanEdit(false); // read-only
fields.add(ldapField);
DataSourcePasswordField passwordField = new DataSourcePasswordField(Field.PASSWORD,
MSG.common_title_password(), 100, true);
LengthRangeValidator passwordValidator = new LengthRangeValidator();
passwordValidator.setMin(6);
passwordValidator.setMax(100);
passwordField.setValidators(passwordValidator);
fields.add(passwordField);
DataSourcePasswordField passwordVerifyField = new DataSourcePasswordField(Field.PASSWORD_VERIFY,
MSG.dataSource_users_field_passwordVerify(), 100, true);
MatchesFieldValidator passwordsEqualValidator = new MatchesFieldValidator();
passwordsEqualValidator.setOtherField(Field.PASSWORD);
passwordsEqualValidator.setErrorMessage(MSG.dataSource_users_passwordsDoNotMatch());
passwordVerifyField.setValidators(passwordsEqualValidator);
fields.add(passwordVerifyField);
DataSourceTextField firstNameField = createTextField(Field.FIRST_NAME, MSG.dataSource_users_field_firstName(),
null, 100, true);
fields.add(firstNameField);
DataSourceTextField lastNameField = createTextField(Field.LAST_NAME, MSG.dataSource_users_field_lastName(),
null, 100, true);
fields.add(lastNameField);
DataSourceTextField emailAddressField = createTextField(Field.EMAIL_ADDRESS,
MSG.dataSource_users_field_emailAddress(), null, 100, true);
fields.add(emailAddressField);
EmailValidator emailAddressValidator = new EmailValidator();
emailAddressValidator.setErrorMessage(MSG.dataSource_users_invalidEmailAddress());
emailAddressField.setValidators(emailAddressValidator);
DataSourceTextField phoneNumberField = createTextField(Field.PHONE_NUMBER,
MSG.dataSource_users_field_phoneNumber(), null, 100, false);
fields.add(phoneNumberField);
DataSourceTextField departmentField = createTextField(Field.DEPARTMENT,
MSG.dataSource_users_field_department(), null, 100, false);
fields.add(departmentField);
DataSourceTextField enabledField = createBooleanField(Field.FACTIVE, MSG.dataSource_users_field_factive(), true);
fields.add(enabledField);
DataSourceField rolesField = new DataSourceField(Field.ROLES, FieldType.ANY, "Roles");
fields.add(rolesField);