probleme lors du load HttpService
Bonjour ,
je developpe la une application en flex en pureMVC,
et j ai un probleme lors du loadng du service(HttpService).
le but c est de send un Httpservice pr recuperer un fichier xml et l affecter au provider d un simple datagrid apres avoir cliquer sur un bouton.
le sevice.load() s execute correctement mais apres pr l envoi de la notification et du resultat ça m affiche resultat = null !!!
voici ma facade :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| package org.app
{
import org.app.controller.ApplicationStartupCommand;
import org.app.controller.LoaddataCommand;
import org.puremvc.as3.interfaces.IFacade;
import org.puremvc.as3.patterns.facade.Facade;
public class ApplicationFacade extends Facade implements IFacade
{
public static const STARTUP:String = "startup";
public static const LOAD:String = "LoaddataCommand";
public static const LOAD_COMPLETE:String = "LoadComplete";
public function ApplicationFacade()
{
super();
}
public function startup(app:pureMVCtest):void
{
sendNotification(STARTUP, app);
}
public static function getInstance():ApplicationFacade
{
if (instance == null)
instance = new ApplicationFacade();
return instance as ApplicationFacade;
}
override protected function initializeController():void
{
super.initializeController();
registerCommand(STARTUP, ApplicationStartupCommand);
registerCommand(LOAD,LoaddataCommand);
}
}
} |
la c est ma classe startupCommand :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| package org.app.controller
{
import org.puremvc.as3.interfaces.ICommand;
import org.puremvc.as3.interfaces.INotification;
import org.puremvc.as3.patterns.command.MacroCommand;
public class ApplicationStartupCommand extends MacroCommand implements ICommand
{
override protected function initializeMacroCommand():void
{
addSubCommand(ModelPrepCommand);
addSubCommand(ViewPrepCommand);
}
}
} |
la c est les deux commandes dédiées à la préparation du modèle et de la vue :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| package org.app.controller
{
import org.app.model.LoadProxy;
import org.puremvc.as3.interfaces.ICommand;
import org.puremvc.as3.interfaces.INotification;
import org.puremvc.as3.patterns.command.SimpleCommand;
public class ModelPrepCommand extends SimpleCommand implements ICommand
{
override public function execute(note:INotification):void
{
facade.registerProxy(new LoadProxy());
}
}
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| package org.app.controller
{
import org.app.view.DataMediator;
import org.puremvc.as3.interfaces.ICommand;
import org.puremvc.as3.interfaces.INotification;
import org.puremvc.as3.patterns.command.SimpleCommand;
public class ViewPrepCommand extends SimpleCommand implements ICommand
{
override public function execute(note:INotification):void
{
facade.registerMediator(new DataMediator(note.getBody() as pureMVCtest));
}
}
} |
la c est ma classe qui me permet de charger mon proxy :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| package org.app.controller
{
import org.app.model.LoadProxy;
import org.puremvc.as3.interfaces.ICommand;
import org.puremvc.as3.interfaces.INotification;
import org.puremvc.as3.patterns.command.SimpleCommand;
public class LoaddataCommand extends SimpleCommand implements ICommand
{
private var loadProxy:LoadProxy = new LoadProxy();
override public function execute(note:INotification):void
{
loadProxy=facade.retrieveProxy("LoadProxy") as LoadProxy ;
loadProxy.load();
}
}
} |
ça c est mon proxy :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| package org.app.model
{
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import org.app.ApplicationFacade;
import org.app.view.composant.DataView;
import org.puremvc.as3.interfaces.IProxy;
import org.puremvc.as3.patterns.proxy.Proxy;
import services.servicexml.ServiceXML;
public class LoadProxy extends Proxy
{
public static const NAME:String = "LoadProxy";
public function LoadProxy()
{
super(NAME);
}
public function load():void
{
var delegate:ServiceXML=new ServiceXML();
delegate.LoadService();
}
public function result(data:Object):void
{
var resultat:Array =new Array ((data as ResultEvent).result as Array);
sendNotification(ApplicationFacade.LOAD_COMPLETE,resultat,"Array");
}
}
} |
DataMediator est le médiateur de ma vue principale.
Il est chargé d'enregistrer tous les autres médiateurs de notre application.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| package org.app.view
{
import flash.events.MouseEvent;
import org.app.ApplicationFacade;
import org.app.view.composant.DataView;
import org.puremvc.as3.interfaces.IMediator;
import org.puremvc.as3.patterns.mediator.Mediator;
public class DataMediator extends Mediator implements IMediator
{
public static const Name:String ="DataMediator";
public function DataMediator(viewComponent:pureMVCtest)
{
super(Name,viewComponent );
facade.registerMediator(new DataViewMediator(app.dataView));
this.app.dataView.ButtonLoad.addEventListener(MouseEvent.CLICK,clickHandler);
}
public function clickHandler(event:MouseEvent):void
{
sendNotification(ApplicationFacade.LOAD);
sendNotification(ApplicationFacade.LOAD_COMPLETE);
}
protected function get app():pureMVCtest
{
return viewComponent as pureMVCtest;
}
}
} |
DataViewMediator est à l'écoute de la notification LOAD_MENU_COMPLETE. Dès que celle-ci est envoyée il en récupère le contenu et le charge dans le datagrid .
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| package org.app.view
{
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import org.app.ApplicationFacade;
import org.app.model.LoadProxy;
import org.app.view.composant.DataView;
import org.puremvc.as3.interfaces.IMediator;
import org.puremvc.as3.interfaces.INotification;
import org.puremvc.as3.patterns.mediator.Mediator;
import valueObjects.EmployeeVO;
public class DataViewMediator extends Mediator implements IMediator
{
public static const NAME:String = "DataViewMediator"
public function DataViewMediator(viewComponent:DataView)
{
super(NAME,viewComponent);
}
protected function get dataView():DataView
{
return viewComponent as DataView;
}
override public function listNotificationInterests():Array
{
return[ApplicationFacade.LOAD_COMPLETE]
}
override public function handleNotification(note:INotification):void
{
switch(note.getName())
{
case ApplicationFacade.LOAD_COMPLETE:
dataView.dataGrid.dataProvider = note.getBody() ;
}
}
}
} |
la c mon service
Code:
1 2 3 4 5 6 7 8 9 10
| package services.servicexml
{
public class ServiceXML extends _Super_ServiceXML
{
}
} |
...
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
package services.servicexml
{
import com.adobe.fiber.core.model_internal;
import com.adobe.fiber.services.wrapper.HTTPServiceWrapper;
import mx.rpc.AbstractOperation;
import mx.rpc.AsyncToken;
import mx.rpc.http.HTTPMultiService;
import mx.rpc.http.Operation;
import com.adobe.serializers.xml.XMLSerializationFilter;
[ExcludeClass]
internal class _Super_ServiceXML extends com.adobe.fiber.services.wrapper.HTTPServiceWrapper
{
private static var serializer0:XMLSerializationFilter = new XMLSerializationFilter();
// Constructor
public function _Super_ServiceXML()
{
// initialize service control
_serviceControl = new mx.rpc.http.HTTPMultiService();
var operations:Array = new Array();
var operation:mx.rpc.http.Operation;
var argsArray:Array;
operation = new mx.rpc.http.Operation(null, "LoadService");
operation.url = "http://adobetes.com/f4iaw100/remotedata/employees.xml";
operation.method = "GET";
operation.serializationFilter = serializer0;
operation.properties = new Object();
operations.push(operation);
_serviceControl.operationList = operations;
model_internal::initialize();
}
public function LoadService() : mx.rpc.AsyncToken
{
var _internal_operation:mx.rpc.AbstractOperation = _serviceControl.getOperation("LoadService");
var _internal_token:mx.rpc.AsyncToken = _internal_operation.send() ;
return _internal_token;
}
} |
au final j arrive pas a recuperer le .result et mon dataprovider reste null .
si vous pouvez m aider. :cry:
merci d avance