The Modeler in LiveCycle ES2 ships with several built-in validation classes, which you can apply to the models properties using the Styles definition. Obviously these standard classes don’t cover all use cases, especially not validation behavior that is specific to a non-US region for example. One of the cool things about Fiber models is that you can extend them using custom ActionScript code, so that you can use your custom validation classes in your projects (I plan to write another article on working with custom methods in your model by overwriting the generated value objects).
So, you can add and apply your own validation classes to the model. You just need to refer to your custom class in the Style validation annotation of the property. First, copy the validation class itself into the correct folder of your Workbench project. That’s also the trickiest part within the LiveCycle Modeler (compared to doing this for the Flash Builder modeler). The FB modeler generates the code into your Flex project folder and you can easily find it, but Workbench doesn’t generate the code in the directory where all your other projects are located (on Vista/Win7 that is C:UsersusernameWorkbench ES2). I am not exactly sure why, but I think because the model generated classes are mostly temp files that don’t have to be checked into the server (downside is that you need to backup modifications of custom classes yourself).
That ‘temp’ folder that stores all model generated classes is much deeper on your disk drive. On my system it’s C:UsersusernameAppDataRoamingAdobeLiveCycleES2Guidesgenerated. Here you find subfolders structured per LiveCycle application. For your project, find the folder where the generated myModel.as and myModel.swf files are located. Consider this folder the ‘root’ that is used by the compiler, so this is where yoy copy your custom validator classes to.
The last step is to define the style validation annotations within the property. Basically you’d define your property like this:
The ValidatorClass item defines the class path, and in this case the ‘allowedFormatChars’ is one of the parameters that is used by that class. Now make sure that Workbench recompiles your class (just move an entity a few pixels, save and the recompile will hapen). Now your custom validator class is compiled into the model itself and you are ready to use the related properties within your guide!
ps: Workbench will inform you on compilation errors if you made errors in your class.
Original article at http://www.drflex.eu/2010/03/livecycle-es2-guides-adding-custom-validation-classes-to-your-model/.