czw888
|
|
« on: April 08, 2010, 06:29:58 » |
|
I have a difficult to use puremvc+Blazeds now . First see blow's code: OrgchartDelegate:
package com.czw.apps.cbank.model.business { import com.czw.apps.cbank.model.vo.OrgchartVO; import mx.rpc.IResponder; import mx.rpc.remoting.RemoteObject;
public class OrgchartDelegate { private var responder:IResponder; private var service:Object; public function OrgchartDelegate(responder:IResponder) { service=new RemoteObject(); service.destination="myOrgchartLogicFlex"; service.makeObjectsBindable=true; service.showBusyCursor=true; this.responder=responder; } public function getAllOrgchart():void{ var call:Object=service.getAllOrgchart(); call.addResponder(this.responder); } public function getParentOrgchart(departmentid:String):void{ var call:Object=service.getAllOrgchart(departmentid); call.addResponder(this.responder); } public function updateOrgchart(orgchartVO:OrgchartVO):void{ var call:Object=service.updateOrgchart(orgchartVO); call.addResponder(this.responder); } } }
OrgchartProxy:
package com.czw.apps.cbank.model { import com.czw.apps.cbank.ApplicationFacade; import com.czw.apps.cbank.model.business.OrgchartDelegate; import com.czw.apps.cbank.model.vo.OrgchartVO; import mx.collections.ArrayCollection; import mx.rpc.Responder; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; import mx.controls.Alert; import org.flexunit.runner.Result; import org.puremvc.as3.interfaces.IProxy; import org.puremvc.as3.patterns.proxy.Proxy;
public class OrgchartProxy extends Proxy implements IProxy { public static const NAME:String="OrgchartProxy"; public var errorStatus:String; public var currentOrgchart:OrgchartVO; public function OrgchartProxy(data:Object=null) { super(NAME,data); } public function getAllOrgchart():void{ var delegate:OrgchartDelegate=new OrgchartDelegate(new Responder(ongetAllOrgchartResult,onFault)); delegate.getAllOrgchart(); } public function ongetAllOrgchartResult(event:ResultEvent):void{ data =event.result as ArrayCollection; this.sendNotification(ApplicationFacade.GET_ALL_ORGCHART_SUCESS); } public function getParentOrgchart(departmentid:String):void{ var delegate:OrgchartDelegate=new OrgchartDelegate(new Responder(ongetParentResult,onFault)); delegate.getParentOrgchart(departmentid); } public function ongetParentResult(event:ResultEvent):void{ currentOrgchart=event.result as OrgchartVO; this.sendNotification(ApplicationFacade.GET_PARENT_ORGCHART_SUCESS); } public function updateOrgchart(orgchartVO:OrgchartVO):void{ var delegate:OrgchartDelegate=new OrgchartDelegate(new Responder(onUpdateResult,onFault)); delegate.updateOrgchart(orgchartVO); } public function onUpdateResult(event:ResultEvent):void{ this.sendNotification(ApplicationFacade.UPDATE_ORGCHART_SUCESS); } public function onFault(event:FaultEvent):void{ this.errorStatus=event.fault.faultString; Alert.show(this.errorStatus,"Error"); } public function get orgchartList():ArrayCollection{ return data as ArrayCollection; } } }
if call OrgchartProxy .getAllOrgchart()when I disconnection the database,the getAllOrgchart function will call onFault function. but if call OrgchartProxy.updateOrgchart(vo) when I disconnection the database,the updateOrgchart function not call onFault.
|