Creating Custom Validators Types

You can create a custom validator by extending the validator class, com.nexaweb.plugin.validation.validators.Validator, and overriding #validate.

To create a custom validator type, follow these steps.

1. Create a textField or passwordField component and assign it an ID by editing its properties.

2. Right click in a UI file and select Data > Create Data Validator.
The Create Data Validator wizard appears.

3. Complete the Create Data Validator wizard similar to the following:

image\img00310.gif

Type: Click on validator in the list of validators displayed on the left.

ID: Specify a unique ID for this instance of this validator.

class: Either create a new class to use for this validator or select an existing one. To use a new class, leave the check box selected. To use an existing class, click in the Create new validator class checkbox to de-select it and then specify the class in the text field or click browse to search for one.

Value: Specifies the ID of a textField or passwordField in the UI file and the text attribute of that field to validate.

Trim: Specifies whether Nexaweb removes white space from the beginning and end of the value specified as the value attribute before validation occurs. Set to false, does not trim white space, by default. Set to true to trim white space.

onSuccess: Specifies an MCO or Macro event to run - for example, to display a success message - upon successful validation. Press Ctrl+space bar for the syntax for specifying an existing event handler. Or click Advanced to define a new event handler. See Connecting Business Logic to the User Interface for more information on creating an event handler.

onFailure: Specifies an MCO or Macro event to run - for example, to display a failed message if input does not meet validation requirements. Press Ctrl+space bar for the syntax for specifying an existing event handler. Or click Advanced to define a new event handler. See Connecting Business Logic to the User Interface for more information on creating an event handler.

 Click Next.
If you specified an existing class to use for this validator, the Validator Summary
dialog appears. Go on to Step 6.
If you selected to create a new class for this validator, The New Validator Class wizard appea
rs similar to the following:

image\img00311.gif

4. For more information on creating a class, see Creating Managed Client Objects. Also, see the Nexaweb Platform documentation on Creating a Validator. When you finish specifying the class information, click Next.
The Validator Summary
dialog appears.

image\img00312.gif

5. Verify the validator information and click Back to change it or click Next to continue.
When you click Next, the Bind validator with event attribute
dialog appears.

image\img00313.gif

6. Select the component and component attribute to invoke the validator.
To review your selection in a summary
dialog, click Next.
To add the validator, click Finish.
The validator appears in the validator folder in the Validator view.