Skip to end of metadata
Go to start of metadata

GateIn Portal 3.5 includes a user-configurable validator that can be applied to input fields of different bundled portlets. Currently, this validator is only used to configure the validation of username formats in the user account, user registration and group membership portlets, though the architecture allows for configurable validation to be used in different contexts if needed.

The validator can be configured via properties in the file found in the GateIn configuration directory. By default, this directory is found at $JBOSS_HOME/standalone/configuration/gatein/ if you are using JBoss Application Server or $TOMCAT_HOME/gatein/conf/ if you are using Tomcat.

The architecture supports several configurations that can be activated and associated to specific instances of the user-configurable validator when they are created and assigned to fields in portlets. We will only concern ourselves with the currently supported use cases, which are creation/modification of a username during registration/modification of a user and group membership assignments.

Validator configuration

A configuration is created by adding an entry to using the gatein.validators. prefix followed by the name of the configuration, a period '.' and the name of the validation aspect you want to configure. The user-configurable validator currently supports four different aspects per configuration, as follows, where {configuration} refers to the configuration name:

  • gatein.validators.{configuration}.length.min: Minimal length of the validated field.
  • gatein.validators.{configuration}.length.max: Maximal length of the validated field.
  • gatein.validators.{configuration}.regexp: Regular expression to which values of the validated field must conform.
  • gatein.validators.{configuration}.format.message: Information message to display when the value of the validated field does not conform to the specified regular expression.

Only two configurations are currently supported by GateIn:

  • username which configures the validation of usernames when they are created/modified.
  • groupmembership which configures the validation of usernames in the context of group memberships.

If you want to make sure that your users use an email address as their usernames, you could use the following configuration:

If you do not change the configuration of the validator, the username will be validated as follows:
  • Length must be between 3 and 30 characters.
  • Only lowercase letters, numbers, undescores (_) and period (.) can be used.
  • No consecutive undescores (_) or period (.) can be used.
  • Must start with a letter.
  • Must end with a letter or number.
Some components that leverage GateIn depend on usernames being all lowercase. Therefore, it is strongly recommended that you only accept the lowercase usernames.

Developer information

The user-configurable validator is implemented by the org.exoplatform.webui.form.validator.UserConfigurableValidator class. Please refer to its documentation for more details.

To use a specific validator configuration to validate a given field value, add the validator to the field where configurationName is a String representing the name of the configuration to use:

The validator instance can then be configured by adding the relevant information in, for example:

Alternatively, a resource key can also be passed to the addValidator method to specify which localized message should be used in case a validation error occurs, for example configurationName as follows:

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Jan 10, 2013

    ENTERPRISE WRITERS: This info is contained in the Installation Guide