我正在使用 RobotLegs、LiveCycle DS 和 Java 开发一个 Flex 应用程序。我正在尝试使用 LCDS 实现更新功能,但遇到了一些奇怪的行为:
这是 RobotLegsexecute
命令中的 ActionScript 代码,用于执行更新:
var token:AsyncToken = services.requestService.commit(new Array(model.currentRequestDetail));
responder = new AsyncResponder(resultHandler, faultHandler, token);
if ( token ) token.addResponder(responder);
model.currentRequestDetail
我要更新的是一个 RequestDetail 对象:
[Managed]
[RemoteClass(alias="be.fgov.mobilit.td.lcds.vo.RequestDetail")]
public class RequestDetail {
public var id:Number;
public var request:Request;
public var task:Task;
/**
* Constructor
*/
public function RequestDetail() {
}
}
第一次执行 Actionscript 代码时,一切正常。函数很好地返回了 AsyncToken services.requestService.commit()
,resultHandler 按预期执行,我的对象在 GUI 中更新。
但是,第二次执行此代码时,我的services.requestService.commit()
函数返回一个空值,并且我的 resultHandler 永远不会到达。我怀疑我们甚至没有到达 java 汇编器。
这就是我声明 DataService 的方式:
var requestDetailService:DataService = new DataService("requestDetail");
requestDetailService.autoCommit = false;
resultHandler 和 faultHandler 都有正确的签名:
resultHandler(result:Object, token:Object = null)
faultHandler(result:Object, token:Object = null)
我们还使用了一个自定义的 java 汇编器,代码如下:
package be.fgov.mobilit.td.lcds.assemblers;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import be.fgov.mobilit.td.lcds.vo.RequestDetail;
import flex.data.ChangeObject;
import flex.data.assemblers.AbstractAssembler;
public class RequestAssembler extends AbstractAssembler {
public RequestAssembler() {
// TODO Auto-generated constructor stub
}
public RequestDetail getRequest(Map<String, Object> identity) {
return ServiceUtility.getLcdsService().getRequestDetail(identity);
}
public List<ChangeObject> syncRequest(List<ChangeObject> changes) {
Iterator<ChangeObject> iterator = changes.iterator();
ChangeObject co;
while (iterator.hasNext()) {
co = (ChangeObject) iterator.next();
if (co.isUpdate()) {
co = doUpdate(co);
}
}
return changes;
}
private ChangeObject doUpdate(ChangeObject co) {
RequestDetail requestDetail = (RequestDetail) co.getNewVersion();
co.setNewVersion(ServiceUtility.getLcdsService().updateRequestDetail(requestDetail));
return co;
}
}
这是汇编程序的配置:
<destination id="request">
<properties>
<source>be.fgov.mobilit.td.lcds.assemblers.RequestAssembler</source>
<scope>application</scope>
<metadata>
<identity property="id" />
<identity property="task" />
</metadata>
<server>
<get-method>
<name>getRequest</name>
</get-method>
<sync-method>
<name>syncRequest</name>
</sync-method>
</server>
</properties>
</destination>
长话短说:
有没有人有线索/经验,为什么我第二次执行services.requestService.commit();
它返回一个 null Asynctoken 的函数?
提前谢谢!
根据要求,我从我的服务类中添加了(剥离的)代码。如您所见,没有什么特别的事情发生:
package be.fgov.mobilit.services {
import mx.data.DataService;
import mx.messaging.Consumer;
import mx.messaging.events.MessageEvent;
import mx.rpc.http.HTTPService;
public class LiveCycleServices {
public var requestService:DataService;
public function LiveCycleServices() {
requestService = new DataService("request");
requestService.autoCommit = false;
}
/**
* @param MessageEvent The event object that is dispatched by the Flex framework
* @return void
*
* This message captures the server push messages that need to trigger an update
* of the task list, since this is specific for every client and cannot be
* determined on the server side, coming from LiveCycle.
*/
private function messageHandler(event:MessageEvent):void {
taskListService.refresh();
}
}
}
这是添加我的结果和故障处理程序的地方:
var token:AsyncToken = services.requestService.commit(new Array(model.currentRequestDetail));
var responder:AsyncResponder = new AsyncResponder(resultHandler, faultHandler, token);
if ( token ) token.addResponder(responder);