Comunidad de diseño web y desarrollo en internet online

Ayuda con AMFPHP, Mate y Flex (Enviar y Recibir ObjetosVO)

Citar            
MensajeEscrito el 18 Dic 2009 03:49 pm
Hola, estoy comenzando a desarrollar una aplicación con el framework Mate, junto con AMFPHP para el manejo con la base de datos.

Mi problema es el siguiente, puedo establecer la conexión al archivo php, y enviarme datos simples, como por ejemplo un String, pero al momento de trabajar con objetosVO se me complicó, siempre me queda nulo :(. Acá les dejo la carpeta del proyecto y los archivos php (pesa 424 kb) :

[url=http://depositfiles.com/files/yqy3q2uwz][/url]

Pongo los códigos tmb:

Código ActionScript :

package Eventos
{
   import flash.events.Event;
   import model.HolaVO;
   
   public class lala extends Event
   {
            //.........................................Constants..........................................
      
      public static const LEER_DATOS: String    ="LeerDatos";
      public static const GUARDAR: String = "Guardar";      
      
        public var  pruebaHola: HolaVO;

      //.........................................Constructor..........................................
      public function lala(type:String, bubbles:Boolean=true, cancelable:Boolean=true)
      {
         super(type, bubbles, cancelable);
      }

   }
}


Código Flex :

<?xml version="1.0" encoding="utf-8"?>
<EventMap xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="http://mate.asfusion.com/" 
   xmlns:Servicios="Servicios.*">
   
      <mx:Script>
      <![CDATA[         
         import com.asfusion.mate.core.*;
         import Eventos.*;
         import model.HolaVO;
      ]]>
   </mx:Script>
   
   <EventHandlers type="{lala.LEER_DATOS}">

   <RemoteObjectInvoker id="myRemote" instance="{myService.HolaRO}" method="teDevuelvoUnHelloWorld" >
   <!--   <resultHandlers>
            <CallBack method="handleResult" arguments="{resultObject}"/>
      </resultHandlers>
         
      <faultHandlers>
            <CallBack method="handleFault" arguments="{fault.faultDetail}"/>
      </faultHandlers> -->
                  <resultHandlers>
                     <ServiceResponseAnnouncer type="result">                        
                     </ServiceResponseAnnouncer>
                  </resultHandlers>
                  
                  <faultHandlers>
                      <ServiceResponseAnnouncer type="fault">                         
                      </ServiceResponseAnnouncer>
                  </faultHandlers>
   </RemoteObjectInvoker>
   </EventHandlers>
   
<!-- /////////////////////Services///////////////////////////  -->
   
<Servicios:Services id="myService">   </Servicios:Services> 
</EventMap>


Código Flex :

<mx:Object   xmlns="http://mate.asfusion.com/" xmlns:mx="http://www.adobe.com/2006/mxml">
    
<mx:RemoteObject id="HolaRO" showBusyCursor="true" destination="Hola" source="Hola" makeObjectsBindable="true"/>      
   
</mx:Object>


Código ActionScript :

package model
{ 

[Bindable]
    [RemoteClass(alias='mode.HolaVO')]

   public class HolaVO
   {
      public var hola: String;
      public var mundo: String;
   }
}



Código Flex :

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300"
   xmlns:mate="http://mate.asfusion.com/">

   <mx:Script>
      <![CDATA[
   
         import Eventos.*;
         import mx.controls.Alert;
         import com.asfusion.mate.events.ResponseEvent;
         import model.*;
         //...........................................handleResult........................................
      
       [Bindable] public var pruebaHola : HolaVO;
         
         public function handleResult(text: ResponseEvent):void
         {
         //ti.text = event.result.toString();   
         Alert.show("FUNCIONAAAAAA: " + pruebaHola.hola );   
         }
         
         //...........................................handleFault........................................
         
         public function handleFault(text: ResponseEvent):void
         {
            Alert.show("No funcione: "+ text.fault);
         }
         
         //...........................................submitForm........................................
         
            private function enviar():void 
         { 
            
            this.Despachador.generateEvent();      
         }
         
      ]]>
   </mx:Script>
      
   <mate:Dispatcher id="Despachador" generator="{lala}" 
            type="{lala.LEER_DATOS}">
     
    <mate:ServiceResponseHandler result="handleResult(event)" 
            fault="handleFault(event)" />

<mate:eventProperties>
   <mate:EventProperties pruebaHola="{pruebaHola}">
      
   </mate:EventProperties>
</mate:eventProperties>

    </mate:Dispatcher>

      
   <mx:Button x="167" y="135" label="Button" click="enviar()"/>
   
</mx:Canvas>



Y los php:

Código PHP :

<?php

require_once('./vo/HolaVO.php');


class Hola {

   function teDevuelvoUnHelloWorld() {
$nuevo->hola = "Hello";
$nuevo->world = "World!";
return $nuevo;
   }


}

<?php 


class HolaVO
{

var $_explicitType = 'model.HolaVO';

public $hola;
public $mundo;


}

?>

Por Arteniz

41 de clabLevel



Genero:Masculino  

Programador

firefox
Citar            
MensajeEscrito el 18 Dic 2009 05:52 pm
Ya lo solucioné, lo que había por corregir era que estaba haciendo un Alert con un colaborador erroneo, sólo hay que cambiar en el Alert.show del handleResult pruebaHola.hola por event.result.hola :P
y también debo modificar en el php Class Hola ,

$nuevo->world = "World!";

por $nuevo->mundo = "World!";

lo demás estaba bien... jaja, me volví loco buscando en otros lados xD

Por Arteniz

41 de clabLevel



Genero:Masculino  

Programador

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.