thanks for your response. I will look at isStructureValid(). I used it ages ago but the example i tried from the flex docs wasn't making any async calls. but i will take a look again.
--- In flexcoders@yahoogroups.com, "jgserrault" <[EMAIL PROTECTED]> wrote: > Could you perhaps just use/call the isStructureValid() function of > the validator class whenever you return from the remote call. Seems > like it might be the easiest way to deal with this AND just give one > last check of the form fields. > > > --- In flexcoders@yahoogroups.com, "bhaq1972" <[EMAIL PROTECTED]> wrote: > > Hi > > > > I'm doing an async call (using the Pending call procedure) in my > > extended TextInput (which has a <mx:Validator> object attached). > > > > I save the validator object reference in a class variable (so i can > > use it in the result handler later on), but when I return to the > > result handler i dont get the red box appearing. > > > > I have a work around for this but i wanted to make sure i wasn't > > doing something wrong. > > > > Here's some test code. You will need to make your own async call > > (mine's checking to see if a code exists and returning a > > description...standard stuff!). > > > > > > test.mxml > > --------- > > <?xml version="1.0" encoding="utf-8"?> > > <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" > > xmlns:nx="*" backgroundColor="#C0DCC2"> > > > > <mx:RemoteObject id="remote1" > > endpoint="http://localhost/flashremoting/gateway.aspx" > > source="FlexTestClassLibrary.Class1" showBusyCursor="true" > > fault="alert(event.fault.faultstring, 'Error')"/> > > > > <mx:TextArea id="out" width="200" height="100" text="(1)Enter > > anything (except 'test') into 1st textinput. this gives a redbox [a > > synchronous validation]. (2)Enter an invalid code into the 2nd > > textinput [asynchronous validation]"/> > > > > <mx:Panel title="anothertest" height="150" > > > <mx:FormItem label="sync:" required="true"> > > <nx:myTextInput id="ti_1"/> > > </mx:FormItem> > > <mx:FormItem label="async" required="true"> > > <nx:myTextInput id="ti_2" lookup="true"/> > > </mx:FormItem> > > <mx:Text id="text1"/> > > </mx:Panel> > > > > </mx:Application> > > > > > > > > myTextInput.mxml > > ---------------- > > <mx:TextInput xmlns:mx="http://www.macromedia.com/2003/mxml" > > > > > <mx:Model id="theModel"> > > <text>{text}</text> > > </mx:Model> > > > > > > <mx:Validator field="theModel.text" validate="customValidate( > > event.validator, event.value )" listener="this" /> > > > > > > <mx:Script> > > <![CDATA[ > > > > public var lookup:Boolean=false; // can be set in test.mxml > > private var validator; > > > > function customValidate( validator, value ) > > { > > > > if(!lookup) //synchronous validation > > { > > if(value != "test") > > { > > validator.validationError( > > null, "need to enter the word 'test'", null ); > > } > > } > > else //asynchronous validation > > { > > // save the refernce to validator to be used > > in result handler > > this.validator = validator; > > > > // do db lookup > > var remote1 = > > mx.core.Application.application.remote1; > > var sql:String = "select DESCRIPTION from > > PRODUCT where CODE='" + value + "'"; > > > > var call = remote1.GetDescription(sql); > > call.onResult = mx.utils.Delegate.create > > (this, returnDBLookup); > > } > > } > > > > function returnDBLookup(result) > > { > > // if nothing returned show red box > > if(result.length <= 0) > > { > > this.validator.validationError( > > null, "you've enterd an invalid code", null ); > > mx.core.Application.application.text1.text > > = "DB LOOKUP ERROR"; > > } > > else > > { > > mx.core.Application.application.text1.text = > > result.getItemAt(0).DESCRIPTION; > > } > > } > > > > ]]> > > </mx:Script> > > > > </mx:TextInput> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/