我正在使用flex,Java和sql server的webmapping應用程序,我試圖從數據庫中填充我的組合框,但我只是得到像這樣的結果[Object Object] [Object Object] [Object Object ] [對象對象]而不是獲得正確的值的字段,這是代碼,我認爲一切正常,但它不工作!你能幫助我找到我在搞什麼!從數據庫填充組合框
所以首先這是我的類的代碼,它選擇從數據庫
public class RapportDao {
public Connection conectar(){
Connection cn = null;
String connectionUrl = "jdbc:sqlserver://localhost\\SQLEXPRESS;databaseName=mabase;user=sa;password=sa;";
try
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
cn = DriverManager.getConnection(connectionUrl);
}
catch(Exception ex)
{
System.out.println("Error : " + ex.getMessage());
}
return cn;
}
public ArrayList<Rapport> Selection() {
Connection conn = conectar();
ArrayList<Rapport> list = null;
if (conn!=null){
try{
Rapport pr = null;
String a;
list = new ArrayList<Rapport>();
String sql = "select IntituleChap from Rapport";
Statement st = conn.createStatement();
ResultSet rs=st.executeQuery(sql);
while (rs.next())
{
a=rs.getString("IntituleChap");
pr = new Rapport();
pr.setIntituleChap(a);
list.add(pr);
}
}
catch(SQLException e) {
// System.out.print(e.getMessage());
System.out.println("Error = " + e.getMessage());
}
}else
{
}
return list;
}
}
柱(Intitule Chapitre),並且這是用於組合框我的ActionScript代碼
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:esri="http://www.esri.com/2008/ags"
minWidth="1000" minHeight="700" applicationComplete="application1_applicationCompleteHandler(event)">
<fx:Script>
<![CDATA[
import spark.components.ComboBox;
private function getTypeprojetResult(event : ResultEvent):void
{
//Alert.show(""+event.result);
}
protected function application1_applicationCompleteHandler(event:FlexEvent):void
{
RemoteRapportDao.Selection()
}
]]>
<fx:Declarations>
<s:RemoteObject id="RemoteRapportDao"
destination="RapportDaoDest"
fault="onFault(event)">
<s:method name="Selection" result="getTypeprojetResult(event);"/>
</s:RemoteObject>
</fx:Declarations>
<s:ComboBox id="cmb" x="10" y="13" width="162" labelField="IntituleChap" dataProvider="{RemoteRapportDao.Selection.lastResult}" />
RemoteRapportDao:是ID RemoteObject 選擇():我的服務方法
任何人都可以幫助我?
你應該分配數據提供程序在功能上getTypeprojetResult。這樣'cmb.dataProvider = event.result' –
我提出這樣的:私有函數getTypeprojetResult(事件:的ResultEvent):無效 \t \t \t { \t \t \t \t \t \t \t \t cmb.dataProvider = event.result; \t \t \t} 但我得到這個錯誤: 的靜態類型對象可能無關的類型mx.collections值隱式強制:IList的 – geosevda
什麼在event.result的內容,似乎event.result的類型不落實IList –