wiln / flexlib

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

AdvancedForm registers listeners on its validators too late #142

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
When the AdvancedForm is prefilled with data (eg. a form to modify existing
data). You run into the fact that the form's internal state is notValid
(only becomes valid when all the validators have been triggered once, so
fine for a new form, but not for a form that will not be edited from start
to finish). So if you have bound your submitbutton to the isValid property
of the form, you end up with a form that cannot be submitted, while it
might contain valid data.
To overcome this you want to prevalidate the form, before the user start
editing, by 'manually' calling all the validators in the creationComplete
of the parent of the form. That way the internal form state will be
correct. However the form registers itself as listener on the validators
upon the... creationComplete of its parent(which is just too late), causing
the form to miss the validation events. It would be better to register
those listeners upon 'initialise'.

What version of the product are you using? On what operating system?
FlexLib 2.4

Please provide any additional information below.
A solution is not to register the listeners on 'creationComplete' of the
parent, but on the 'initialise'. That way the listeners are up and running,
and you allow the user to prevalidate the form in the creationcomplete. 

Suggested solution: line 215 AdvancedForm.as
/**
* Creates snapshot of values for reseting
*/
override protected function childrenCreated():void {
   super.childrenCreated();
   // Find Validators and add EventListeners
   parent.addEventListener( "initialize", setValidatorListenerEvents );

   this.parent.addEventListener( KeyboardEvent.KEY_DOWN, myKeyDownHandler,
false, 0, true );
}

Original issue reported on code.google.com by ingo....@gmail.com on 11 Jul 2008 at 1:02

GoogleCodeExporter commented 9 years ago
See issue 25 for a cleaner solution. It is better to leave the registering of 
the
validator listeners on creationcomplete.

Original comment by ingo....@gmail.com on 18 Jul 2008 at 8:05

GoogleCodeExporter commented 9 years ago
marking as duplicate of issue 25, since the original poster points to the patch 
in
issue 25 as a better fix

Original comment by dmcc...@gmail.com on 8 Jan 2009 at 5:29