IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Flex Discussion :

probleme lors du load HttpService


Sujet :

Flex

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Futur Membre du Club
    Homme Profil pro
    Inscrit en
    Mars 2011
    Messages
    3
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Mars 2011
    Messages : 3
    Par défaut 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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    package services.servicexml
    {
     
    public class ServiceXML extends _Super_ServiceXML
    {
     
     
    }
     
    }
    ...
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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.
    merci d avance

  2. #2
    Futur Membre du Club
    Homme Profil pro
    Inscrit en
    Mars 2011
    Messages
    3
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Mars 2011
    Messages : 3
    Par défaut ...
    plus précisément ça m affiche ce message :
    Error #1009: Il est impossible d'accéder à la propriété ou à la méthode d'une référence d'objet nul

Discussions similaires

  1. [ADO] Probleme lors de l'execution d'une requete...
    Par NoisetteProd dans le forum Bases de données
    Réponses: 4
    Dernier message: 04/06/2004, 12h43
  2. Réponses: 13
    Dernier message: 10/05/2004, 16h49
  3. [MYSQL] Probleme lors de la compilation
    Par Nasky dans le forum Autres éditeurs
    Réponses: 10
    Dernier message: 24/02/2004, 17h04
  4. probleme lors du passage de paramètre
    Par maxmj dans le forum ASP
    Réponses: 4
    Dernier message: 18/11/2003, 00h15
  5. problem lors de l'ecriture d'un fichier
    Par gemai dans le forum C
    Réponses: 20
    Dernier message: 29/08/2003, 15h01

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo