12 Replies Latest reply on Oct 1, 2010 6:53 AM by Claudiu Ursica

    Interface issue

    nikos101 Level 2

      I'm getting an error Call to a possibly undefined method attemptLogin. however I have defined that in the interface

       

       

      package controller
      {
          import org.robotlegs.mvcs.Command;
         
          import service.AuthenticationService;
          import service.IAuthenticationService;
         
          import view.events.LDAP_LoginEvent;
         
          public class AuthenticateLoginCommand extends Command
          {
             
              [Inject]
              public var event:LDAP_LoginEvent;
             
              [Inject]
              public var service:IAuthenticationService;
             
             
              override public function execute():void
              {
                 
                  service.attemptLogin(event.username,event.password,event.domain);
           
        }
          }
      }

       

      _________________________________________________________

      package service
      {
          public interface IAuthenticationService
          {
              /**
               *
               * @param username
               * @param password
               * @param domain optional, useful for ldap stuff
               *
               */       
              function attemptLogin(username:String,password:String,domain:String= null):void;
          }
      }

        • 1. Re: Interface issue
          Claudiu Ursica Level 4

          Does your service.AuthenticationService class implement the interface properly?

          How do you map the interface to the class into the injector inside the context?

           

          C

          1 person found this helpful
          • 2. Re: Interface issue
            nikos101 Level 2

            yes its is correct implementation, i map it in a command :

             

            package controller.setup
            {
                import events.ApplicationConfigurationEvent;
               
                import org.robotlegs.mvcs.Command;
               
                import service.AuthenticationService;
                import service.IAuthenticationService;
               
                public class ConfigureServiceCommand extends Command
                {
                    override public function execute():void
                    {
                       injector.mapSingletonOf(IAuthenticationService, AuthenticationService);
                       
                        dispatch(new ApplicationConfigurationEvent(ApplicationConfigurationEvent.CONFIGURE_MODEL));
                    }
                   
                   
                }
            }

            • 3. Re: Interface issue
              nikos101 Level 2

              fyi the service :

               

              package service
              {
                  import mx.managers.CursorManager;
                  import mx.rpc.events.FaultEvent;
                  import mx.rpc.events.ResultEvent;
                  import mx.rpc.remoting.RemoteObject;
                 
                  import org.robotlegs.mvcs.Actor;
                 
                  public class AuthenticationService extends Actor implements IAuthenticationService
                  {
                     
                      public function attemptLogin(username:String,password:String,domain:String=null):void
                      {
                          CursorManager.setBusyCursor();
                          if(domain)
                              amfRemote.attemptLogin(username,password,domain);
                          else
                              amfRemote.attemptLogin(username,password);
                         
                         
                      }

                     
                     
                      public function AuthenticationService()
                      {
                          init();
                      }
                     
                     
                      private var amfRemote:RemoteObject;
                     
                     
                     
                      public function init():void
                      {
                          amfRemote  = new RemoteObject();
                          amfRemote.destination = "amfphp";
                          amfRemote.source = "CF.AuthenticationService";
                          amfRemote.addEventListener(FaultEvent.FAULT, faultHandler);
                          amfRemote.addEventListener(ResultEvent.RESULT, resultHandler);
                      }
                     
                     
                     
                     
                      private function resultHandler(event:ResultEvent):void
                      {
                          CursorManager.removeBusyCursor();
                         
                      }
                     
                      private function faultHandler(event:FaultEvent):void
                      {
                          trace(event.fault);
                      }
                     
                     
                  }
              }

              • 4. Re: Interface issue
                Claudiu Ursica Level 4

                Your code looks fine to me. I need to run it myself to see why is not working. Maybe I'll have sometime later on today. Usually that kind of error happens when you have a typo in the class implementing the interface. WHat is the line of code thqat is throwing the error? this one"

                 

                service.attemptLogin(event.username,event.password,event.domain); ?

                 

                C

                • 5. Re: Interface issue
                  nikos101 Level 2

                  23

                   

                   

                  for some reason when i hover over service fb doesnt recognise its of type IAuthenticationService

                   

                   

                   

                  [Inject]
                          public var service:IAuthenticationService;
                         
                         
                          override public function execute():void
                          {
                             
                              service.attemptLogin(event.username,event.password,event.domain);
                          }

                  • 6. Re: Interface issue
                    nikos101 Level 2

                    23 in this code, the command that needs the service

                     

                    package controller
                    {
                        import org.robotlegs.mvcs.Command;
                       
                        import service.AuthenticationService;
                        import service.IAuthenticationService;
                       
                        import view.events.LDAP_LoginEvent;
                       
                        public class AuthenticateLoginCommand extends Command
                        {
                           
                            [Inject]
                            public var event:LDAP_LoginEvent;
                           
                            [Inject]
                            public var service:IAuthenticationService;
                           
                           
                            override public function execute():void
                            {
                               
                                service.attemptLogin(event.username,event.password,event.domain);

                            }
                        }
                    }

                    • 7. Re: Interface issue
                      nikos101 Level 2

                      such an annoying issue anyone else experianced anything like this?


                      • 8. Re: Interface issue
                        nikos101 Level 2

                        it tried it with another interface and that one works:

                         

                             package controller
                        {
                            import org.robotlegs.mvcs.Command;
                           
                            import service.IAuthenticationService;
                            import service.IStockPriceService;
                           
                            import view.events.LDAP_LoginEvent;
                           
                            public class AuthenticateLoginCommand extends Command
                            {
                               
                                [Inject]
                                public var event:LDAP_LoginEvent;
                               
                                [Inject]
                                public var service:IAuthenticationService;
                               
                                [Inject]
                                public var stockPriceService:IStockPriceService;
                               
                               
                               
                                override public function execute():void
                                {
                                   
                                    service.attemptLogin(event.username,event.password,event.domain);
                                    stockPriceService.loadQuotes();
                           
                                }
                            }
                        }

                         

                         

                         

                         

                         

                        that interface goes like this:

                         

                        package service
                        {
                           
                            public interface IStockPriceService
                            {
                                function loadQuotes():void;
                            }
                           
                        }

                        • 9. Re: Interface issue
                          nikos101 Level 2

                          again the interface causing the problems is:

                           

                          package service
                          {
                              public interface IAuthenticationService
                              {
                                 
                                  function attemptLogin(username:String,password:String,domain:String):void;
                              }
                          }

                          • 10. Re: Interface issue
                            nikos101 Level 2

                            figured it, it was a conflict with the package name

                             

                             

                            GGGGGGGGGGGGGRRRRRRRRRRRRRRRRRRR

                            • 11. Re: Interface issue
                              nikos101 Level 2

                              figured it, it was a conflict with the package name

                               

                               

                              GGGGGGGGGGGGGRRRRRRRRRRRRRRRRRRR

                              • 12. Re: Interface issue
                                Claudiu Ursica Level 4

                                Happens from time to time , it is good that you figured it out.

                                 

                                C