9 Replies Latest reply on Aug 2, 2006 11:30 PM by yoganss@yahoo.com

    ArrayCollection in flex and ArrayList in java

    yoganss@yahoo.com Level 1

      Hi mydears of this world
      Here i come along with my problem with the hope that some one can resolve it
      i am totally new to flex and i am working only for the past 3 days in flex. and i learned a little bit.
      i want to get the database values which is received from java object to flex datagrid with the help of data provider.
      i did it pretty well according to me. But i could not produce the result in the data grid . since i am very new . i dont know what is happening.

      my code is here , please help me.

      My mxml file : Myadmin.mxml

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical">
      <mx:RemoteObject id="ber" destination="berth" showBusyCursor="true" fault="faultHandler(event)" >
      <mx:method name="getBerth" result="resultHandler(event)"/>

      <mx:Panel id="topPanel" title="MyDatabase" width="100%" height="40%" enabled="true">
      <mx:TextArea id="sql" width="100%" height="100%"/>

      <mx:Button label="Execute" click="handleSend()"/>


      <mx:Panel id="bottomPanel" title="Results" width="100%" height="60%" enabled="true">
      <mx:DataGrid id="dg" dataProvider="{result}" width="100%" height="100%"/>

      <mx:Label id="resultLabel" text ="Onumae puriyale ulgathulae" />


      import mx.rpc.events.*;
      import mx.collections.*;
      import mx.controls.*;
      import mx.utils.ObjectUtil;

      //cached empty ArrayCollection so that we don't keep creating
      //new ones

      private var emptyResults:ArrayCollection = new ArrayCollection();

      public var result:ArrayCollection = emptyResults;

      private function resultHandler(event:ResultEvent):void
      Alert.show("event.result array results", ObjectUtil.toString(event.result as ArrayCollection));
      result = ArrayCollection(event.result);
      var myCursor:IViewCursor=result.createCursor();
      var oldLength:int=result.length;



      private function faultHandler(event:FaultEvent):void
      Alert.show(event.fault.faultString, "Error");

      private function handleSend():void





      My java Object : Berth.java

      package samples.sqladmin;
      import java.sql.*;
      import java.util.*;
      import java.io.*;

      public class Berth

      public static void main(String args[])throws Exception
      ArrayList list = getBerth();
      System.out.println("The List is =" + list);

      public static ArrayList getBerth()throws Exception {
      Connection con = null;
      Statement st = null;
      ResultSet rs = null;
      ResultSetMetaData rsmd = null;
      ArrayList list = new ArrayList();
      HashMap row=null;
      }catch(ClassNotFoundException cnfe){
      con = DriverManager.getConnection("jdbc:odbc:Jurong","","");
      st = con.createStatement();
      String sql = "select * from berth ";
      rsmd = rs.getMetaData();
      int colCount = rsmd.getColumnCount();
      while (rs.next()) {
      row=new HashMap();
      for (int i = 1; i <= colCount; i++) {
      row.put(rsmd.getColumnName(i), rs.getString(i));

      catch(SQLException sqle){
      System.out.println("enna da yogans eeeeee....");

      if(con != null)
      if(st != null)
      return list;



      my remote-config file is:

      <destination id="berth">

      i got the array collection object in flex but it is not giving the values which received in java

      please help me .
      Thanks in advance