com.ibm.xsp.validator
Interface ClientSideValidator

All Known Implementing Classes:
ConstraintValidator, DateTimeRangeValidator, DoubleRangeValidatorEx2, ExpressionValidator, LengthValidatorEx, LongRangeValidatorEx2

public interface ClientSideValidator

This interface defines a validator that implements client side validation.


Method Summary
 java.lang.String generateClientSideValidation(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Generate client side validation, a snippet of browser JavaScript in a single line, creating an instance of a Validator object matching the format described in xspClientDojo.js, the attachValidator function.
 java.lang.String getInvalidMessage()
          Unlike server-side validators which display different error messages depending on the exact way that validation fails, client side validators usually have only one error message.
 

Method Detail

generateClientSideValidation

java.lang.String generateClientSideValidation(javax.faces.context.FacesContext context,
                                              javax.faces.component.UIComponent component)
                                              throws java.io.IOException
Generate client side validation, a snippet of browser JavaScript in a single line, creating an instance of a Validator object matching the format described in xspClientDojo.js, the attachValidator function.

The file xspClientDojo.js is reference in the source of every XPage. The version with comments is installed with Designer under the Data/domino/js folder, in a file named xspClientDojo.js.uncompressed.js.

The constructor of the Validator object should be passed any values needed to perform the validation (e.g. for a range validator the minimum and maximum values would be included). The translated error message to display if the error occurs should be passed to the validator too. Generally the server-side validators translate a default error message and allow the page designer to override the default in a "message" property.

Parameters:
context - The current context.
component - The control whose value will be validated, usually a UIInput.
Returns:
snippet of browser JavaScript to create the Validator object.
Throws:
java.io.IOException

getInvalidMessage

java.lang.String getInvalidMessage()
Unlike server-side validators which display different error messages depending on the exact way that validation fails, client side validators usually have only one error message. For example, you might have server-side messages "Value is less than minimum {0}" and "Value is greater than maximum {1}", but client-side you would only have one message "Value is not in the allowed range {0} to {1}".

This method may return different values depending on the configuration of the validator.

Returns:
message to display when the value is invalid.