| Key points: |
- All server-side code, wrapping the FoodAndDrinks database, was generated by WebORB, as shown in the prerequisite screencast.
- WebORB-gnenerated client-side code, in the FAD_Client package of the src package, provides the client-side interface to the server-side database.
- 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 findAll() 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 findAll()'s empty result.
- The database query that is invoked by findAll() is completed ASYNCHRONOUSLY—that is, eventually, long after findAll()'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.
|