求教 flex 传递 arraycollection to java
代码如下:
flex :
XML code<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
private var testArray:ArrayCollection;
private function tmpClick():void{
testArray=new ArrayCollection();
var employee:Object = new Object();
employee.Month="2009/08"
employee.QTY = "21";
employee.UnitPrice = "21";
employee.Revenue="12";
employee.TesterQty = "21";
employee.HistoryQTY = "12";
employee.HistoryUnitPrice = "21";
employee.Remark = "11";
testArray.addItem(employee);
remoteObject.test(testArray);
}
private function testHandler(event:ResultEvent):void{
Alert.show(event.result as String);
}
]]>
</mx:Script>
<mx:RemoteObject id="remoteObject" destination="flex_java_interface" showBusyCursor="true">
<mx:method name="test" result="testHandler(event)"/>
</mx:RemoteObject>
<mx:Button click="tmpClick()"/>
</mx:Application>
后台java类:
Java codepublic String test(List tmpMonthForecastArray){
int i=0;
String tmpMonth="";
String tmpQTY="";
String tmpUnitPrice="";
String tmpRevenue="";
String tmpTesterQTY="";
String tmpHistoryUnitPrice="";
String tmpRemarkString="";
String result=null;
Map stateObj;
try {
for(i=0;i<tmpMonthForecastArray.size();i++){
stateObj=new HashMap();
stateObj=(Map) tmpMonthForecastArray.get(i);
tmpMonth=stateObj.get("Month").toString();
tmpQTY=stateObj.get("QTY").toString();
tmpUnitPrice=stateObj.get("UnitPrice").toString();
tmpRevenue=stateObj.get("Revenue").toString();
tmpTesterQTY=stateObj.get("TesterQTY").toString();
tmpHistoryUnitPrice=stateObj.get("HistoryUnitPrice").toString();
tmpRemarkString=stateObj.get("Remark").toString();
result=result+tmpMonth;
}
return result;
} catch (Exception e) {
// TODO: handle exception
return null;
}
}
我觉得应该返回的是:2009/08,但实际返回的是空,请问老大们是不是这样写错了?
还请给个解决方法,小弟谢谢!