Results 1 to 6 of 6

Thread: not going to errorlistener

  1. #1
    Join Date
    Apr 2011
    Posts
    10

    Default not going to errorlistener

    Hello,

    I'm making,with a friend, a mobile application at this moment for our thesis. We're using spring actionscript to get data from the server. We're doing this with commands.

    Now our problem is that if we want to refresh our page. We also want to detect if there's stil internetconnection. If not we want to show a messagebox.
    So we add an addErrorListener to our command:

    Code:
    protected function refreshImage_clickHandler(event:MouseEvent):void
    {
    var cmd:LoadStartupDataAfterLoginCommand=new LoadStartupDataAfterLoginCommand(ServiceLocator.getInstance().context);
    cmd.addCompleteListener(loadDataAfterLogin_completeHandler);
    cmd.addErrorListener(refresh_errorHandler);
    cmd.execute();
    }
    When we debug and plug out ethernetcable and hit refresh he never goes into our refresh_errorHandler function. But in our console we can see that we have an ERROR:
    Code:
    ERROR - TMSNG.Service - Error during server communication on method 'getAvailableEventTypes': [RPC Fault faultString="error" faultCode="Channel.Call.Failed" faultDetail="NetConnection.Call.Failed: HTTP: Failed"]
    Can anybody help us?

    Kind regards,

    Thibault Heylen

  2. #2
    Join Date
    Dec 2008
    Location
    Brussels
    Posts
    407

    Default source

    Hi there,

    just from your description its very hard for me to decide where to problem might be. I would need to see the exact implementation of your LoadStartupDataAfterLoginCommand class before I can say anything sensible about this.

    Can you please attach your sources so I may have a look?

    thanks in advance,

    cheers,

    Roland

  3. #3
    Join Date
    Apr 2011
    Posts
    10

    Default

    Dear,

    Thank you for the response. Here you can view our code:
    Code:
    package com.traficon.tmsng.client.mobile.command
    {
    	import com.traficon.domain.EventMessageCollection;
    	import com.traficon.domain.ModelLocator;
    	import com.traficon.tmsng.client.mobile.view.LogonView;
    	import com.traficon.tmsng.service.IEventTypeService;
    	import com.traficon.tmsng.service.ISystemService;
    	import com.traficon.tmsng.service.IUserService;
    	
    	import flash.events.IEventDispatcher;
    	
    	import org.as3commons.lang.Assert;
    	import org.springextensions.actionscript.context.IApplicationContext;
    	import org.springextensions.actionscript.core.command.event.CommandEvent;
    	
    	import spark.components.View;
    
    	public class LoadStartupDataAfterLoginCommand extends AbstractLoadStartupDataCommand
    	{
    		/*----------------------------------variabels----------------------------------*/
    		
    		private var m_applicationContext:IApplicationContext;
    		private var m_systemService:ISystemService;
    		
    		/*----------------------------------Public Methods----------------------------------*/
    		
    		public function LoadStartupDataAfterLoginCommand(applicationContext:IApplicationContext)
    		{
    			
    			m_applicationContext = applicationContext;
    			m_systemService = applicationContext.getObject("systemService");
    			
    			var userService:IUserService = applicationContext.getObject("userService");
    			var realTimeEventMessages:EventMessageCollection = applicationContext.getObject("realTimeEventMessages");
    			var modelLocator:ModelLocator = ModelLocator.getInstance();
    
    	
    			addCommandWithResourceKey(
    				new GetAvailableEventConfigurationCommand(applicationContext.getObject("eventTypeService"),modelLocator),
    				"main.loading.eventtypes");
    			addCommandWithResourceKey(
    				new GetCustomNameEventTypesCommand(m_systemService,modelLocator),
    				"main.loading.customEventTypeNames");
    			addCommandWithResourceKey( 
    				new GetDetectorsCommand(applicationContext.getObject("detectorService"),modelLocator.detectors),
    				"main.loading.detectors");
    			addCommandWithResourceKey(
    				new GetDetectorGroupsCommand(applicationContext.getObject("detectorGroupService"),modelLocator.detectorGroups),
    				"main.loading.detectorgroups");
    			addCommandWithResourceKey(
    				new GetMessageSourcesTreeCommand(applicationContext.getObject("messageSourceService"),modelLocator),
    				"main.loading.messagesourcestree");
    			addCommandWithResourceKey(
    				new GetMessageSourcesHardwareTreeCommand(applicationContext.getObject("messageSourceService"),modelLocator),
    				"main.loading.messagesourcestree");
    			
    			addCommandWithResourceKey(
    				new GetOpenMessagesCommand(applicationContext.getObject("eventMessageHistoryRemoteObject"),modelLocator.realTimeEventMessages),
    				"main.loading.openmessages",
    				afterGetOpenMessages);
    		}
    		
    		/*----------------------------------Private Methods----------------------------------*/
    		
    		private function afterGetOpenMessages(event:CommandEvent):void{
    			IEventDispatcher(event.command);
    		}
    		
    		
    
    	}
    }
    this extens another class:
    Code:
    package com.traficon.tmsng.client.mobile.command
    {
    	import com.traficon.domain.ModelLocator;
    	import com.traficon.tmsng.client.mobile.components.MessageBox;
    	import com.traficon.tmsng.client.mobile.view.LogonView;
    	
    	import flash.utils.Dictionary;
    	
    	import mx.logging.ILogger;
    	import mx.logging.Log;
    	import mx.resources.ResourceManager;
    	
    	import org.as3commons.lang.StringUtils;
    	import org.as3commons.logging.LoggerFactory;
    	import org.springextensions.actionscript.core.command.CompositeCommand;
    	import org.springextensions.actionscript.core.command.ICommand;
    	import org.springextensions.actionscript.core.command.event.CommandEvent;
    	import org.springextensions.actionscript.core.operation.OperationEvent;
    
    	public class AbstractLoadStartupDataCommand extends CompositeCommand
    	{
    
    		/*----------------------------------variabels----------------------------------*/
    		private var m_commandMessages:Dictionary = new Dictionary();
    		private var m_commandCallbacks:Dictionary = new Dictionary();
    		/*--------------------------------------Constructor--------------------------------------*/
    		public function AbstractLoadStartupDataCommand()
    		{
    			
    			failOnFault = true;
    			addEventListener(CommandEvent.EXECUTE,executeCommandHandler);
    			//addErrorListener(errorHandler);
    		}
    		/*------------------------------------Protected Methods------------------------------------*/
    		protected function addCommandWithResourceKey(command:ICommand,resourceKey:String = null,callback:Function = null):void{
    			addCommand(command);
    			
    			if(StringUtils.hasText(resourceKey)){
    				m_commandMessages[command] = ResourceManager.getInstance().getString("resources",resourceKey);
    			}
    			if(callback != null)
    			{
    				m_commandCallbacks[command] = callback;
    			}
    		}
    		/*------------------------------------Private Methods-----------------------------------*/
    		private function executeCommandHandler(event:CommandEvent):void{
    			var message:String = m_commandMessages[event.command];
    			
    			var callback:Function = m_commandCallbacks[event.command];
    			if(callback != null){
    				callback.apply(null,[event]);
    			}
    		}
    		private function errorHandler(event:OperationEvent):void{
    			if(!ModelLocator.getInstance().loggingOut){
    				
    			}
    		}
    		
    	}
    }
    Hopefully you can help us.

    Thank you in advance.

    Kind regards,

    Thibault Heylen

  4. #4
    Join Date
    Dec 2008
    Location
    Brussels
    Posts
    407

    Default error propagation

    hey there,

    the error you are seeing in your trace is coming from a service class whose instance, I presume, is used by one of the commands that you are adding to the composite command.
    Can you verifiy that these command dispatch an error event once they encounter an error from the service?
    Its still hard for me to see where the problem lies, but I suspect that somewhere an eror is not properly being propagated.

    cheers,

    Roland

  5. #5
    Join Date
    Apr 2011
    Posts
    10

    Default

    Dear,

    sorry for the late response. And thank you for the help.
    I will check all my files on the errorlisterners.

    Thank you for the help

    Thibault Heylen

  6. #6
    Join Date
    Apr 2011
    Posts
    10

    Default

    it's solved! thanks for the help
    it was an errorlistner that was not handeld

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •