Tengo 2 ABM, cada uno con un Evento y despachadores para el alta, baja, modificación, y leer los datos de la base. Si yo desde mi primer ABM hago un dispach del evento para leer, se me ejecutan los dos result de los 2 ABM, cuando no debería suceder esto.
Este es el EventMap:
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:Services="Services.*">
<mx:Script>
<![CDATA[
import com.asfusion.mate.events.EventProperties;
import Model.*;
import com.asfusion.mate.core.*;
import Events.*;
import mx.controls.Alert;
[Bindable] public var tipoDoc: TipoDocumentoVO;
[Bindable] public var dependencia: DependenciaVO;
]]>
</mx:Script>
<!--HANDLERS PARA CREAR DOCUMENTO -->
<EventHandlers type="{ABMTipoDocumentoEvent.NUEVO}">
<RemoteObjectInvoker id="myRemote1" instance="{myService.TipoDocumentoRO}"
method="nuevo" arguments="{event.tipoDoc}">
<resultHandlers>
<ServiceResponseAnnouncer type="result">
</ServiceResponseAnnouncer>
</resultHandlers>
<faultHandlers>
<ServiceResponseAnnouncer type="fault">
</ServiceResponseAnnouncer>
</faultHandlers>
</RemoteObjectInvoker>
</EventHandlers>
<EventHandlers type="{ABMTipoDocumentoEvent.MODIFICAR}">
<RemoteObjectInvoker id="myRemote2" instance="{myService.TipoDocumentoRO}" method="modificar"
arguments="{event.tipoDoc}">
<resultHandlers>
<ServiceResponseAnnouncer type="result">
</ServiceResponseAnnouncer>
</resultHandlers>
<faultHandlers>
<ServiceResponseAnnouncer type="fault">
</ServiceResponseAnnouncer>
</faultHandlers>
</RemoteObjectInvoker>
</EventHandlers>
<EventHandlers type="{ABMTipoDocumentoEvent.ELIMINAR}">
<RemoteObjectInvoker id="myRemote3" instance="{myService.TipoDocumentoRO}"
method="eliminar" arguments="{event.tipoDoc}" >
<resultHandlers>
<ServiceResponseAnnouncer type="result">
</ServiceResponseAnnouncer>
</resultHandlers>
<faultHandlers>
<ServiceResponseAnnouncer type="fault">
</ServiceResponseAnnouncer>
</faultHandlers>
</RemoteObjectInvoker>
</EventHandlers>
<EventHandlers type="{ABMTipoDocumentoEvent.GET_ALL}">
<RemoteObjectInvoker id="myRemote4" instance="{myService.TipoDocumentoRO}" method="getAll" >
<resultHandlers>
<ServiceResponseAnnouncer type="result">
</ServiceResponseAnnouncer>
</resultHandlers>
<faultHandlers>
<ServiceResponseAnnouncer type="fault">
</ServiceResponseAnnouncer>
</faultHandlers>
</RemoteObjectInvoker>
</EventHandlers>
<!-- ///////////////////////////////ABM DEPENDENCIAS //////////////////////////////////////////// -->
<EventHandlers type="{ABMDependenciasEvent.NUEVO}">
<RemoteObjectInvoker id="myRemote5" instance="{myService.DependenciaRO}"
method="nuevo" arguments="{event.dependencia}">
<resultHandlers>
<ServiceResponseAnnouncer type="result">
</ServiceResponseAnnouncer>
</resultHandlers>
<faultHandlers>
<ServiceResponseAnnouncer type="fault">
</ServiceResponseAnnouncer>
</faultHandlers>
</RemoteObjectInvoker>
</EventHandlers>
<EventHandlers type="{ABMDependenciasEvent.MODIFICAR}">
<RemoteObjectInvoker id="myRemote6" instance="{myService.DependenciaRO}" method="modificar"
arguments="{event.dependencia}">
<resultHandlers>
<ServiceResponseAnnouncer type="result">
</ServiceResponseAnnouncer>
</resultHandlers>
<faultHandlers>
<ServiceResponseAnnouncer type="fault">
</ServiceResponseAnnouncer>
</faultHandlers>
</RemoteObjectInvoker>
</EventHandlers>
<EventHandlers type="{ABMDependenciasEvent.ELIMINAR}">
<RemoteObjectInvoker id="myRemote7" instance="{myService.DependenciaRO}"
method="eliminar" arguments="{event.dependencia}" >
<resultHandlers>
<ServiceResponseAnnouncer type="result">
</ServiceResponseAnnouncer>
</resultHandlers>
<faultHandlers>
<ServiceResponseAnnouncer type="fault">
</ServiceResponseAnnouncer>
</faultHandlers>
</RemoteObjectInvoker>
</EventHandlers>
<EventHandlers type="{ABMDependenciasEvent.GET_ALL}">
<RemoteObjectInvoker id="myRemote8" instance="{myService.DependenciaRO}" method="getAllDependencia" >
<resultHandlers>
<ServiceResponseAnnouncer type="result">
</ServiceResponseAnnouncer>
</resultHandlers>
<faultHandlers>
<ServiceResponseAnnouncer type="fault">
</ServiceResponseAnnouncer>
</faultHandlers>
</RemoteObjectInvoker>
</EventHandlers>
<!-- /////////////////////Services/////////////////////////// -->
<Services:Services id="myService"> </Services:Services>
</EventMap>
Y este es el ABM:
Código Flex :
[Bindable]
public var dependencia : DependenciaVO ;
//-------------------------RESULT--------------------------------------------
public function handleResultNuevo(event: ResponseEvent):void{
Alert.show("La dependencia ha sido agregada");
}
public function handleResultModificar(event: ResponseEvent):void{
Alert.show("La dependencia ha sido modificada");
}
public function handleResultEliminar(event: ResponseEvent):void{
Alert.show("La dependencia ha sido eliminada");
}
public function handleResultGetAll(event:ResponseEvent):void{
this.dgDependencias.dataProvider = event.result;
}
//----------------------FAULT-----------------------------------------------
public function handleFaultNuevo(event: ResponseEvent):void{
Alert.show("No se pudo agregar la dependencia.");
}
public function handleFaultModificar(event: ResponseEvent):void{
Alert.show("No se pudo modificar la dependencia");
}
public function handleFaultEliminar(event: ResponseEvent):void{
Alert.show("No se pudo eliminar la dependencia");
}
public function handleFaultGetAll(event:ResponseEvent):void{
Alert.show("No se pudo traer los datos desde la base.");
}
public function enviarNuevo():void{
dependencia = new DependenciaVO();
dependencia.dependencia = txtDependencia.text;
dependencia.firmante = txtFirmante.text;
this.DespachadorNuevo.generateEvent();
this.DespachadorGetAll.generateEvent();
limpiarCampos();
}
public function enviarModificar():void{
dependencia = new DependenciaVO();
//cargo el objeto seleccionado en el grid con el id
dependencia.idDependencia = this.dgDependencias.selectedItem.idDependencia;
//Asigno los valores de los txt al objeto
dependencia.dependencia = this.txtDependencia.text;
dependencia.firmante = this.txtFirmante.text;
//aca se lanza el evento
this.DespachadorModificar.generateEvent();
this.DespachadorGetAll.generateEvent();
limpiarCampos();
}
public function enviarEliminar():void{
dependencia = new DependenciaVO();
//recupero el id para ejecuar la consulta para eliminar
dependencia.idDependencia = this.dgDependencias.selectedItem.idDependencia;
this.DespachadorEliminar.generateEvent();
this.DespachadorGetAll.generateEvent();
limpiarCampos();
}
//Trae todos los datos de la base de datos. actualizar el Grid
public function enviarGetAll():void{
this.DespachadorGetAll.generateEvent();
}
public function seleccion():void{
txtDependencia.text = this.dgDependencias.selectedItem.dependencia;
txtFirmante.text = this.dgDependencias.selectedItem.firmante;
}
public function limpiarCampos():void{
txtDependencia.text =null;
txtFirmante.text = null;
}
]]>
</mx:Script>
<mx:Label styleName="MainTitle" text="Dependencias"> </mx:Label>
<mx:VBox>
<mx:HBox>
<mx:Label text="Dependencia:" />
<mx:TextInput id="txtDependencia" />
<mx:Label text="Firmante:" />
<mx:TextInput id="txtFirmante" />
</mx:HBox>
<mx:HBox>
<mx:Button label="Nuevo" id="btnNuevo" click="enviarNuevo()"/>
<mx:Button label="Modificar" id="btnModificar" click="enviarModificar()"/>
<mx:Button label="Eliminar" id="btnEliminar" click="enviarEliminar()"/>
</mx:HBox>
<mx:DataGrid id="dgDependencias" width="100%" height="100%" itemClick="seleccion()">
<mx:columns>
<mx:DataGridColumn headerText="Dependencia" dataField="dependencia" width="200" textAlign="center"/>
<mx:DataGridColumn headerText="Firmante" dataField="firmante" width="200" textAlign="center"/>
</mx:columns>
</mx:DataGrid>
</mx:VBox>
<!-- Lanzadores de Eventos -->
<mate:Dispatcher id="DespachadorNuevo" generator="{ABMDependenciasEvent}"
type="{ABMDependenciasEvent.NUEVO}">
<mate:ServiceResponseHandler result="handleResultNuevo(event)"
fault="handleFaultNuevo(event)" />
<mate:eventProperties>
<mate:EventProperties dependencia="{dependencia}">
</mate:EventProperties>
</mate:eventProperties>
</mate:Dispatcher>
<mate:Dispatcher id="DespachadorModificar" generator="{ABMDependenciasEvent}"
type="{ABMDependenciasEvent.MODIFICAR}">
<mate:ServiceResponseHandler result="handleResultModificar(event)"
fault="handleFaultModificar(event)" />
<mate:eventProperties>
<mate:EventProperties dependencia="{dependencia}"></mate:EventProperties>
</mate:eventProperties>
</mate:Dispatcher>
<mate:Dispatcher id="DespachadorEliminar" generator="{ABMDependenciasEvent}"
type="{ABMDependenciasEvent.ELIMINAR}">
<mate:ServiceResponseHandler result="handleResultEliminar(event)"
fault="handleFaultEliminar(event)" />
<mate:eventProperties>
<mate:EventProperties dependencia="{dependencia}"></mate:EventProperties>
</mate:eventProperties>
</mate:Dispatcher>
<mate:Dispatcher id="DespachadorGetAll" generator="{ABMDependenciasEvent}"
type="{ABMDependenciasEvent.GET_ALL}">
<mate:ServiceResponseHandler result="handleResultGetAll(event)"
fault="handleFaultGetAll(event)" />
</mate:Dispatcher>
</mx:Panel>
