Hi,
I posted a related message last week about how I am unable to
retrieve an array of data from a remote object.
I am a newbie and I've been able to call Java methods when
they return a simple String. However, I am unable to get an array
of Java objects.
I have a datagrid in my application that has to be populated
by calling a method of a remote object.
The remote object (Java class looks like this).
public class PlayerService {
......
// This is the method that gets called.
public Player[] getPlayersAsArray() {
Player[] players = new Player[3];
Player rahul = new Player("Rahul",,"Dravid");
Player sachin = new Player("Sachin","Tendulkar");
Player saurav = new Player("Saurav","Ganguly");
players[0] = rahul;
players[1] = sachin;
players[2] = saurav;
return players;
}
}
I've configured the destination in my service-config.xml as
......
<destination id="PlayerService">
<properties>
<source>rpc.playerinfo.PlayerService</source>
<scope>application</scope>
</properties>
</destination>
.....
My mxml application code is given below
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"><mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.collections.ArrayCollection;
import rpc.playerinfo.Player;
import mx.utils.ArrayUtil;
[Bindable]
public var players:ArrayCollection;
public function handlePlayersResult(event: ArrayCollection)
{
//then set the event result which is being sent into this
function to the playerList
players = event;
}
]]>
</mx:Script>
<mx:RemoteObject id="playMe" destination="PlayerService"
showBusyCursor="true">
<mx:method name="getPlayersAsArray"
result="handlePlayersResult(event.result as ArrayCollection)"/>
</mx:RemoteObject>
<mx:DataGrid dataProvider="{players}" width="100%"
creationComplete="playMe.getPlayersAsArray()">
<mx:columns>
<mx:DataGridColumn dataField="firstName"
headerText="FirstName"/>
<mx:DataGridColumn dataField="lastName"
headerText="LastName"/>
</mx:columns>
</mx:DataGrid>
</mx:Application>
When I run the application, the datagrid is blank with just
the header text. I see the headers 'FirstName' and 'LastName' but
the
grid isn't populated by any values.
Thank you so much.