|
introduction get started articles manual tutorials reference docs case studies knowledge base goodies screenshots demos echoes Carousel zone home forums downloads bugs mailing list |
XUI Zone - goodies
Custom XValidationFactory class The custom XValidationFactory class is extended in this library which allows three custom XBaseValidator to be added to your applications. These are the FunctionValidation, NumberValidation and IntegerValidation classes. This customer validation factory can be included in your project by setting the ValidationFactory property in the startup properties file as shown in Listing 1
Listing 1 - The startup properties
An example of the validations file referred to by the Validations property is shown in Listing 2
Listing 2 - An sample validations file
This file declares a validation for each of the custom validations being handled by the custom XValidationFactory. The type attribute is checked by the factory in order to find out the type of validation to be created. If it doesn't know the type then the construction of the validation is passed over to the super class. Now a page can be declared which makes use of these validations. A sample page is shown in Listing 3
Listing 3 - A sample page using the validations
The page contains three inputs for each of the custom validations. The button calls the checkValidations function of the page and if there are any exceptions they can be seen in the console. The checkChars function is defined in the TestPage class as shown in The sample checkChars function Listing 4.
Listing 4 - The sample checkChars function
Of course this is just a frivolous implementation of the FunctionValidation class but you can see how versatile it can be in XUI applications Files
You need to be logged in to download the files for this article
comments If you were logged in you could rate this article or add a comment. |