Mapping Java ResultSet to Flex

Ask a Question related to Macromedia Flex General Discussion, Design and Development.

  1. #1

    Default Mapping Java ResultSet to Flex

    I finally got java and flex working together as a team yesterday. After
    creating simple programs such as fetching string and calculating factorial, I
    went over to sql.

    I fetched some sql records and displayed them in a datagrid successfully.
    Unfortunately, I didnt save the results and I can't reaccomplish that again.
    Here's the code I used (as far as I know)

    I am not sure what did I change, as it worked before and populated the
    datagrid with the sql data. Now when I print result, all I see is lots of
    [object Object]. So the data is coming through, just not sure if its the right
    data, or how to map it to datagrid.

    Thanks



    [Java function to fetch sql records]

    public List getStudents() {
    List students = new ArrayList();
    try {
    String sql = "SELECT * FROM student";
    Statement stmt = db.createStatement();
    ResultSet results = stmt.executeQuery(sql);
    while (results.next()) {
    students.add(results);
    }
    }
    catch (Exception e) { e.printStackTrace(); }

    return students;
    }


    [flex code to map it to datagrid]

    <mx:RemoteObject id="studentRecords" destination="studentsService"/>

    <mx:Button label="get data" click="Student.getStudents()"/>
    <mx:DataGrid dataProvider="{studentRecords.getStudents.result}" >
    <mx:columns>
    <mx:DataGridColumn headerText="first name" dataField="firstname"/>
    <mx:DataGridColumn headerText="last name" dataField="lastname"/>
    <mx:DataGridColumn headerText="middle name" dataField="middlename"/>
    <mx:DataGridColumn headerText="email" dataField="email"/>
    </mx:columns>
    </mx:DataGrid>

    Anurag Mishra Guest

  2. Similar Questions and Discussions

    1. java ResultSet size
      let's say I did a simple query on a database like show tables; in java, i get a ResultSet how can I get the total number of rows in the ResultSet?...
    2. flex with java
      i am new to flex1.5 i need some simple coding for connecting java objects and methods with flex components. my project is to develop a training...
    3. [JAVA] - To Make training of JAVA, help me Underestand FLEX and AS 3.0 ?
      Do you finds that to make training of JAVA, it helps me to better understand the FLEX and the 3.0? Or it does not make much difference? Sorry...
    4. mapping Flex ValueObjects to CFCs
      First, my setup is ColdFusion MX7 and Flex 1.5 sharing the same context root (/) on JRun4 (updater 6). I have been having (what I think are)...
    5. JDBC ResultSet - Where is its stored? DB2 client app or Java program's JVM?
      When a Java program executes a SQL query using JDBC, is the ResultSet data stored in the DB2 Client process or in the JVM for the Java program? The...
  3. #2

    Default Mapping Java ResultSet to Flex

    Hi,
    Please use <mx:DataGrid dataProvider="{studentRecords.getStudents.lastResu lt}" >
    insetead of <mx:DataGrid dataProvider="{studentRecords.getStudents.result}" >

    This will resolve your issue.
    Faisal Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139