morrislchg / flexlib

Automatically exported from code.google.com/p/flexlib
0 stars 0 forks source link

AdvancedForm ignores custom validators #191

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a custom validator:
http://livedocs.adobe.com/flex/3/html/help.html?content=validators_2.html
2. Use the custom validator with an AdvancedForm

What is the expected output? What do you see instead?

Expected:
The AdvancedForm will register listeners for VALID and INVALID events on
the custom Validator.

Actual:
The AdvancedForm ignores the custom validators because they are not an
Instance of the Validator class but are subclasses of Validator.

What version of the product are you using? On what operating system?
http://flexlib.googlecode.com/files/flexlib-.2.4.zip

Please provide any additional information below.

The offending code:

/**
*   Loop through all Validtors at the same level as the Form and set a Event
listener for Valid and Invalid
*/
private function setValidatorListenerEvents( event:Event ):void
{
......

// Loop over all parentDocument's properties looking for Validators
    for each (var a:XML in classInfo..accessor) {
        try {
            if( container[ a.@name ] is Validator ) {

The solution:
Using recursive object introspection at the scope of the AdvancedForm to
find Validators is not practical. Store the set of validators for the
AdvancedForm in an explicitly declared Array. 

<mx:Array id="formValidators">
    <mx:StringValidator></mx:StringValidator>
    <mx:CustomValidator></mx:CustomValidator>
</mx:Array>

validators = formValidators

I will attach a patch shortly.

Original issue reported on code.google.com by dtba...@gmail.com on 26 Jan 2009 at 6:46

GoogleCodeExporter commented 8 years ago
I discovered my problem. I had not declared an 'id' property on my custom 
validator.
If an 'id' is not declared, the validator is not XML described as an 'accessor' 
but
as a 'variable'.

So, everyone make sure you give all o your validators and 'id'.

Please close this issue as resolved.

Thanks,
Derek Basch

Original comment by dtba...@gmail.com on 26 Jan 2009 at 8:28