Announcement Announcement Module
Collapse
No announcement yet.
Multiple Asynchronous Call from Flex Dashboard Application Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multiple Asynchronous Call from Flex Dashboard Application

    Below is my code. I need to populate 4 grids. If service call for one grid is complete it should show data on screen. The plan is it should not wait till all service call to complete.

    In this case, actually resulthandler is called when all service calls are complete. To confirm that, I have put timer in Java in the last service function to wait for 10 seconds. I can see that all three java functions are called one by one and wait till 4th function to complete. I am using Spring Blazeds 1.0.3 libraries.

    I am using parsley and it works with Parsley without using sping blazeds integration. How can I achieve this by using Spring Blazeds integration.

    Spring configuraiton xml is below
    Code:
    	<!-- ******************************************************************** -->
    	<!-- Scan for service layer annotated beans -->
    	<!-- ******************************************************************** -->
    <context:component-scan base-package="com.controller" scoped-proxy="interfaces" />

    Contorller Class

    Code:
    @Service("MyController")
    // @Transactional
    public class MyControllerImpl implements MyController{
    .
    .
    }
    Configuration MXML

    Code:
    		<!-- Parsley Configuration  -->		
    		<mx:RemoteObject id="roMyController" destination="MyController" showBusyCursor="true"/>
    		<pm:MyPM/>
    		<delegates:MyDelegateService/>
    		<spicefactory:DynamicCommand type="com.test.command.MyCommand"
    									 messageType="com.test.events.MyEvent"/>
    PM Class:
    Code:
    	public class MyPM extends Broadcaster
    	{
    		public function MyPM()
    		{
    		}
    		
    		
    		public function loadAllGriddata( paramsMap:Dictionary):void 
          { 
              
             broadcast(new MyEvent(MyEvent.GET_GRID_1, paramsMap)); 
             broadcast(new MyEvent(MyEvent.GET_GRID_2, paramsMap)); 
             broadcast(new MyEvent(MyEvent.GET_GRID_3, paramsMap)); 
             broadcast(new MyEvent(MyEvent.GET_GRID_4, paramsMap)); 
          } 
    
    
    
          [CommandResult] 
          public function myeventResultHandler(result:ResultEvent, trigger:MyEvent):void 
          { 
              
             switch (trigger.type) 
             { 
                case MyEvent.GET_GRID_1: 
                { 
                   // Use Grid 1 output 
                   break; 
                } 
                case MyEvent.GET_GRID_2: 
                { 
                   // Use Grid 2 output 
                   break; 
                } 
                case MyEvent.GET_GRID_3: 
                { 
                   // Use Grid 3 output 
                   break; 
                } 
                case MyEvent.GET_GRID_4: 
                { 
                   // Use Grid 4 output 
                   break; 
                } 
                 
             }          
              
          } 
          
          	[CommandError]
    		public function getMyEventFaultHandler(event:FaultEvent, trigger:MyEvent):void
    		{
    			var errorMessage:ErrorMessage=event.message as ErrorMessage;
    			Alert.show(errorMessage.extendedData.code + '  ' + errorMessage.extendedData.msg);
    		}
    
    }

    Command Class:
    Code:
    
    
    	
    	public class MyCommand
    	{
    		public function MyCommand()
    		{
    		}
    		
    
    		[Inject]
    		public var delegate:MyDelegateService;
    		
    		
    		// Commented to resolve issue
    		//[Command]
    		public function execute(event:MyEvent):AsyncToken
    		{
    			
    			switch (event.type)
    			{
    				case MyEvent.GET_GRID_1:{					
    					return delegate.loadGrid1(event.paramsMap[MyEvent.KEYID]);
    					break;
    				}
    				case MyEvent.GET_GRID_2: {					
    					return delegate.loadGrid2(event.paramsMap[MyEvent.KEYID]);		
    					break;
    				}
    				case MyEvent.GET_GRID_3:{
    					return delegate.loadGrid3(event.paramsMap[MyEvent.KEYID]);		
    					break;
    				}
    				case MyEvent.GET_GRID_4:{					
    					return delegate.loadGrid4(event.paramsMap[MyEvent.KEYID]);		
    					break;
    				}
    			}
    			
    			return null;
    		}
    		
    		
    		
    	}
    Event Class:
    Code:
    	public class MyEvent extends Event
    	{
    		
    		public static const GET_GRID_1:String="GET_GRID_1";
    		public static const GET_GRID_2:String="GET_GRID_2";
    		public static const GET_GRID_3:String="GET_GRID_3";
    		public static const GET_GRID_4:String="GET_GRID_4";
    		
    		public var methodFinder:String;
    		public var paramsMap:Dictionary;
    		
    		
    		public function MyEvent(methodFinder:String, paramsMap:Dictionary)
    		{
    			super(methodFinder);
    			eventType = methodFinder;
    			this.paramsMap=paramsMap;
    		}
    	}
Working...
X