Flex与Java交互(Flex调用java类展示数据)查询显示详细步骤 (三)

2014-11-24 10:41:12 · 作者: · 浏览: 2
corp.setStyle(rs.getString("style"));
corp.setParent(rs.getString("parent"));
corp.setFlag(rs.getString("flag"));
list.add(corp);
}

} catch (Exception e) {
e.printStackTrace();
}finally{
this.closeResultSet(rs);
this.closeStatement(stmt);
this.closeConn(con);
}
return list;
}
}

[html]
< xml version="1.0" encoding="UTF-8" >













tobaccoTrans.dao.impl.CorpDaoImpl




< xml version="1.0" encoding="UTF-8" >








tobaccoTrans.dao.impl.CorpDaoImpl



5、创建Flex项目(这个很关键,详细配置方法 并编写mxml应用程序:

[java]
< xml version="1.0" encoding="utf-8" >
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
initialize="init()"
minWidth="955" minHeight="600">

import mx.collections.ArrayCollection;
import mx.events.FlexEvent;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;

[Bindable]
private function init():void {
// TODO Auto-generated method stub
// 这里拿到的是一个 List 实体对象集合
cdi.getAllCorp("","","","","","");
//remotingtest.showVal();
}

[Bindable]
var corpList:ArrayCollection = new ArrayCollection();
protected function cdi_resultHandler(event:ResultEvent):void {
// TODO Auto-generated method stub
corpList = event.result as ArrayCollection;
}

[Bindable]
protected function cdi_faultHandler(event:FaultEvent):void {

}
]]>


















< xml version="1.0" encoding="utf-8" >
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
initialize="init()"
minWidth="955" minHeight="600">

import mx.collections.ArrayCollection;
import mx.events.FlexEvent;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;

[Bindable]
private function init():void {
// TODO Auto-generated method stub
// 这里拿到的是一个 List 实体对象集合
cdi.getAllCorp("","","","","","");
//remotingtest.showVal();
}

[Bindable]
var corpList:ArrayCollection = new ArrayCollection();
protected function cdi_resultHandler(event:ResultEvent):void {
// TODO Auto-generated method stub
corpList = event.result as ArrayCollection;
}

[Bindable]
protected function cdi_faultHandler(event:FaultEvent):void {

}
]]>


















6、现在可以直接运行mxml文件查看数据,当然这里写的是我的数据库查询,你将你的程序稍稍改动即可。