Flex in this case strictly acts as a pure presentation layer. In other words, the data that is viewable in Flex is prepared and provided by the .NET end. More specifically, it is a remote object with a set number of records in the form of a list. Without the more powerful data mangement features of FDS or WebORB .NET Enterprise, you'd have to handle a number of things manually.

You'd have several facts to consider, for example, whether you allow the user to sort or not. If that's the case you'd have to make sure that you are keeping track of it on the server side too (which column you are sorting on and from what record you are starting the sort, etc.)

Other factors include the data source you are dealing with. .NET has some nifty ways of working with paged datasets, so the only thing that you really need to concentrate on is the data pages you are feeding back to the presentation layer.

No need to cache. For most part you are dealing with a disconnected recordset of a limited set of records anyhow. It wouldn't make sense to keep the 150k+ records in memory.

Instead what you would be doing is passing record pointers back and forth between Flex and the remote object (class library object) so that the class method knows where to start to get the next set of records.

It sounds way more complicated explaining it all. Again, concentrate on using Flex purely to manage the limited number of objects (records) that were passed on the last call and then pass the record id or whatever you want to identify the starting point back to the class method to get you the next set.

If you're doing this with WebORB it actually gets fairly easy to deal with. Here is what your remote object declaration looks like in Flex:

private var service:RemoteObject = new RemoteObject("GenericDestination");

       public function getAlbums():void {
           service.source = "Services.dao.Album.AlbumDAO";
           service.addEventListener(FaultEvent.FAULT,faultHandler);
service.GetAlbums.addEventListener(ResultEvent.RESULT,getAlbumsHandler);
           service.GetAlbums(startID, numberOfRecordsToReturn);
}
Your DTO class in Flex would have a declaration such as the following:

   [Bindable]
   [RemoteClass(alias="Services.dao.Album.Album")]
   public class AlbumInfo
   {
       static private var _instance:AlbumInfo;

       public var ID:Number;
       public var albumName:String;
       public var artFullPath:String;
       public var artThumbPath:String;
       public var yearReleased:String;
       public var itemName:String;
       public var description:String;
       public var storeDescription:String;
       ...
   }

That's not the complete class, but you get the picture. The key is the mapping of the remote class through the alias.

Here is the method on the server in your class library:

Namespace dao.Album

   Public Class AlbumDAO

       Private ConnectString As String
       Private SqlConnection As SqlConnection

Public Function GetAlbums(byval startID as Integer, byval numberOfRecordsToReturn as Integer) As List(Of Album)
           Dim myDT As New DataTable
           Dim myObjects As New List(Of Album)

' Build the list of Album objects based on what is returned from the data store.
            ...

Again, it's not a complete class, but shows you what we are returning. We return a list of Album objects, which Flex will then map properly to the DTO class object.

Inside the GetAlbums function on the server you'd take the startID and use it to get the next set of records, along with how many records to return.

Hope this makes sense. It's not the only way to approach the issue and you'd still have to work around some other issues such as getting the total number of records in the table so you can set your paged navigation.

All Flex would be doing with this scenario is take the list of objects (records) that are returned and put them into an ArrayCollection, which you then can use as a DataProvider for a DataGrid or other component.

       public function getAlbumsHandler(event:ResultEvent):void {
           if (event.result.length > 0) {
               albums = new ArrayCollection(event.result as Array);
               albums.filterFunction = albumsFilterFunc;
               albums.refresh();
           }
       }

The above even includes a filter function, if you need it.

Jurgen


barry.beattie wrote:

Jurgen

please forgive me for asking, could you clarify what's going on at the
.NET end and what the SWF would need to do to get the next "page" of data?

would the 150k+ records be held in a dataset (or whatever) in memory
(cache, session, etc) on the server? (flex would need to send a call
back for next N records to cursor thru them, I assume). A handle to
the cache would need to be sent too?

Reply via email to