Example name: WDMF: findBySQL()
Description: A trivial demonstration of WebORBData Management for Flex (WDMF)'s findBySQL() method.
Prerequisites:
  • (The as-yet unapproved Your First WDMF Application screencast)
Client-side code: Browse  Download
Server-side code: (All generated and deployed by WebORB)
Feature availability:
  • WebORB for .NET Development Mode
  • WebORB for .NET Community Edition
  • WebORB for .NET Enterprise Edition
Run example:
Key points:
  • All server-side code, wrapping the FoodAndDrinks database, was generated by WebORB, as shown in the prerequisite screencast.
  • WebORB also generated client-side code, in the FAD_Client package of the client's src package, to provide the client-side interface to the server-side database (FoodAndDrinks).
  • On the client side, the essential pattern is this:
    • _searchResult is declared to be a bindable ArrayCollection.
    • dataDisplay.dataprovider—the dataprovider property of a Flex DataGrid—is bound to _searchResult. Therefore, whenever _searchResult (or its content) changes, the DataGrid will be updated.
    • The WDMF method findBySQL() is called. The method returns an instance of ArrayCollection.
      • The returned ArrayCollection is empty, but not null.
      • This empty ArrayCollection instance is returned SYNCHRONOUSLY—that is, immediately—without waiting for the database query to be completed.
      • _searchResult is set to findBySQL()'s empty result.
    • The database query that is invoked by findBySQL() is completed ASYNCHRONOUSLY—that is, eventually, long after findBySQL()'s result is assigned to _searchResult.
    • When the query completes, it populates _searchResult with the database query's completed data.
    • Because dataDisplay.dataprovider is bound to _searchResult, dataDisplay.dataprovider is notified of the change to _searchResult's contents, causing dataDisplay to redraw itself.
  • Most of the action takes place in WebORB's runtime, rather than in application-specific code.
  • Many of WDMF's patterns should be familiar to enterprise developers, if only from Martin Fowler's Patterns of Enterprise Application Architecture.
   
Things to try:
  • Read the client-side code's comments carefully. Do you understand the flow of control? The relationship between the synchronous function result returned by findBySQL() and assigned to _searchResult, and the asynchronous loading of _searchResult with data?
See also:
Screencast: [none]
Errata:
  • None yet known.