Re: [flexcoders] Re: How to see if method is implemented in class
I think you could only check public(or else depends on namespace) properties(include methods) for classes. George j_lentzz wrote: > What is the syntax to do this? Just using validate in myObject > returns an error about validate being an undefined property. > > John > --- In flexcoders@yahoogroups.com, "Alex Harui" <[EMAIL PROTECTED]> wrote: > >> If ("validate in someObject) >> >> >> >> >> >> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On >> Behalf Of j_lentzz >> Sent: Tuesday, September 18, 2007 7:26 AM >> To: flexcoders@yahoogroups.com >> Subject: [flexcoders] How to see if method is implemented in class >> >> >> >> Hi, >> >> I've got a problem I'm trying to resolve concerning validating a page >> before submitting it to the server. I have a way to recursively get >> each child on the page. However, I can't figure out a way to see if >> the child has the validate() method implemented. Most of the >> components are extended from TextInputs, ComboBox, etc, where I've >> integrated a validator into each one that is custom for that type. So >> my custom components will have a validate method, however, other >> components - like Images, Buttons, etc - on the page don't have a >> validate method. Is there a way to test that a method exists, before >> trying to call it and causing an exception? >> >> Thanks, >> >> John >> >>
[flexcoders] Re: How to see if method is implemented in class
Alex left out the right double quotes. Since your function is a property of your class like any global variable you can access it with: if("validate" in myObject) {} -or- if(myObject["validate"]) -or- if(myObject.hasOwnProperty("validate")) {} --- In flexcoders@yahoogroups.com, "j_lentzz" <[EMAIL PROTECTED]> wrote: > > What is the syntax to do this? Just using validate in myObject > returns an error about validate being an undefined property. > > John > --- In flexcoders@yahoogroups.com, "Alex Harui" wrote: > > > > If ("validate in someObject) > > > > > > > > > > > > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > > Behalf Of j_lentzz > > Sent: Tuesday, September 18, 2007 7:26 AM > > To: flexcoders@yahoogroups.com > > Subject: [flexcoders] How to see if method is implemented in class > > > > > > > > Hi, > > > > I've got a problem I'm trying to resolve concerning validating a page > > before submitting it to the server. I have a way to recursively get > > each child on the page. However, I can't figure out a way to see if > > the child has the validate() method implemented. Most of the > > components are extended from TextInputs, ComboBox, etc, where I've > > integrated a validator into each one that is custom for that type. So > > my custom components will have a validate method, however, other > > components - like Images, Buttons, etc - on the page don't have a > > validate method. Is there a way to test that a method exists, before > > trying to call it and causing an exception? > > > > Thanks, > > > > John > > >
[flexcoders] Re: How to see if method is implemented in class
Technically, if you plan to call the method wouldn't you also want to verify that it's a function? Something like: if ("validate" in someObject && someObject["validate"] is Function) I suppose it might depend on the possible instance types of someObject. --- In flexcoders@yahoogroups.com, "j_lentzz" <[EMAIL PROTECTED]> wrote: > > Ok. I see now. Very nice. Thanks a bunch. > > John > --- In flexcoders@yahoogroups.com, "Gordon Smith" wrote: > > > > if ("validate" in someObject) > > > > > > > > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > > Behalf Of Alex Harui > > Sent: Tuesday, September 18, 2007 8:10 AM > > To: flexcoders@yahoogroups.com > > Subject: RE: [flexcoders] How to see if method is implemented in class > > > > > > > > If ("validate in someObject) > > > > > > > > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > > Behalf Of j_lentzz > > Sent: Tuesday, September 18, 2007 7:26 AM > > To: flexcoders@yahoogroups.com > > Subject: [flexcoders] How to see if method is implemented in class > > > > Hi, > > > > I've got a problem I'm trying to resolve concerning validating a page > > before submitting it to the server. I have a way to recursively get > > each child on the page. However, I can't figure out a way to see if > > the child has the validate() method implemented. Most of the > > components are extended from TextInputs, ComboBox, etc, where I've > > integrated a validator into each one that is custom for that type. So > > my custom components will have a validate method, however, other > > components - like Images, Buttons, etc - on the page don't have a > > validate method. Is there a way to test that a method exists, before > > trying to call it and causing an exception? > > > > Thanks, > > > > John > > >
[flexcoders] Re: How to see if method is implemented in class
Ok. I see now. Very nice. Thanks a bunch. John --- In flexcoders@yahoogroups.com, "Gordon Smith" <[EMAIL PROTECTED]> wrote: > > if ("validate" in someObject) > > > > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > Behalf Of Alex Harui > Sent: Tuesday, September 18, 2007 8:10 AM > To: flexcoders@yahoogroups.com > Subject: RE: [flexcoders] How to see if method is implemented in class > > > > If ("validate in someObject) > > > > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > Behalf Of j_lentzz > Sent: Tuesday, September 18, 2007 7:26 AM > To: flexcoders@yahoogroups.com > Subject: [flexcoders] How to see if method is implemented in class > > Hi, > > I've got a problem I'm trying to resolve concerning validating a page > before submitting it to the server. I have a way to recursively get > each child on the page. However, I can't figure out a way to see if > the child has the validate() method implemented. Most of the > components are extended from TextInputs, ComboBox, etc, where I've > integrated a validator into each one that is custom for that type. So > my custom components will have a validate method, however, other > components - like Images, Buttons, etc - on the page don't have a > validate method. Is there a way to test that a method exists, before > trying to call it and causing an exception? > > Thanks, > > John >
[flexcoders] Re: How to see if method is implemented in class
What is the syntax to do this? Just using validate in myObject returns an error about validate being an undefined property. John --- In flexcoders@yahoogroups.com, "Alex Harui" <[EMAIL PROTECTED]> wrote: > > If ("validate in someObject) > > > > > > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > Behalf Of j_lentzz > Sent: Tuesday, September 18, 2007 7:26 AM > To: flexcoders@yahoogroups.com > Subject: [flexcoders] How to see if method is implemented in class > > > > Hi, > > I've got a problem I'm trying to resolve concerning validating a page > before submitting it to the server. I have a way to recursively get > each child on the page. However, I can't figure out a way to see if > the child has the validate() method implemented. Most of the > components are extended from TextInputs, ComboBox, etc, where I've > integrated a validator into each one that is custom for that type. So > my custom components will have a validate method, however, other > components - like Images, Buttons, etc - on the page don't have a > validate method. Is there a way to test that a method exists, before > trying to call it and causing an exception? > > Thanks, > > John >
[flexcoders] Re: How to see if method is implemented in class
What is the syntax to do this? Just using validate in myObject returns an error about validate being an undefined property. John --- In flexcoders@yahoogroups.com, "Alex Harui" <[EMAIL PROTECTED]> wrote: > > If ("validate in someObject) > > > > > > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > Behalf Of j_lentzz > Sent: Tuesday, September 18, 2007 7:26 AM > To: flexcoders@yahoogroups.com > Subject: [flexcoders] How to see if method is implemented in class > > > > Hi, > > I've got a problem I'm trying to resolve concerning validating a page > before submitting it to the server. I have a way to recursively get > each child on the page. However, I can't figure out a way to see if > the child has the validate() method implemented. Most of the > components are extended from TextInputs, ComboBox, etc, where I've > integrated a validator into each one that is custom for that type. So > my custom components will have a validate method, however, other > components - like Images, Buttons, etc - on the page don't have a > validate method. Is there a way to test that a method exists, before > trying to call it and causing an exception? > > Thanks, > > John >
[flexcoders] Re: How to see if method is implemented in class
Thanks for all the ideas! I'll see which one works best for my app. Thanks again, John --- In flexcoders@yahoogroups.com, "Alex Harui" <[EMAIL PROTECTED]> wrote: > > If ("validate in someObject) > > > > > > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > Behalf Of j_lentzz > Sent: Tuesday, September 18, 2007 7:26 AM > To: flexcoders@yahoogroups.com > Subject: [flexcoders] How to see if method is implemented in class > > > > Hi, > > I've got a problem I'm trying to resolve concerning validating a page > before submitting it to the server. I have a way to recursively get > each child on the page. However, I can't figure out a way to see if > the child has the validate() method implemented. Most of the > components are extended from TextInputs, ComboBox, etc, where I've > integrated a validator into each one that is custom for that type. So > my custom components will have a validate method, however, other > components - like Images, Buttons, etc - on the page don't have a > validate method. Is there a way to test that a method exists, before > trying to call it and causing an exception? > > Thanks, > > John >
[flexcoders] Re: How to see if method is implemented in class
someComponent.validate == null Remember, methods are properties too. --- In flexcoders@yahoogroups.com, "j_lentzz" <[EMAIL PROTECTED]> wrote: > > Hi, > > I've got a problem I'm trying to resolve concerning validating a page > before submitting it to the server. I have a way to recursively get > each child on the page. However, I can't figure out a way to see if > the child has the validate() method implemented. Most of the > components are extended from TextInputs, ComboBox, etc, where I've > integrated a validator into each one that is custom for that type. So > my custom components will have a validate method, however, other > components - like Images, Buttons, etc - on the page don't have a > validate method. Is there a way to test that a method exists, before > trying to call it and causing an exception? > > Thanks, > > John >