Select to view content in your preferred language

Filling Combobox from database

1280
2
06-05-2014 03:37 PM
SaadiaElaarji
Deactivated User
Hello,

I'm using flex, Java and sql server for webmapping application and i'm trying to fill my combobox from database, this is the code, i think all is right but it doesn't work !!! can you help be to find what i'm messing !!


so first this is the code of my class, it selects a column (Intitule Chapitre) from database

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;
    }
}


and this is my actionscript code for combobox


<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 : is the id RemoteObject
Selection() : my method on the service

but at last i get this instead of labelfields

[ATTACH=CONFIG]34401[/ATTACH]


any one could help me ?
Tags (2)
0 Kudos
2 Replies
raffia
by
Deactivated User
I remember getting this "object"object" output when trying to do the same thing, I got around it by converting the values using toString() function. Did you try that?
0 Kudos
SaadiaElaarji
Deactivated User
Thank you raffialexanian for replying,
But where should i add it ?!!  can you give me an example ?!!
0 Kudos