Wednesday, October 3, 2007

Adobe MAX 2007 - day 3

Final Day



Working with Data in Flex
Tom Lane

What's different about data in Flex?
the role client and server played in architecture
server is doing the work of plugging data into UI (server-side)
ajax server sends abstract data to the client (client-side/server-side hybrid model)
google suggest - selectively employs AJAX to spice up spots
roby partials - async update of a chunk of server generated HTML
Flex is 100% UI on the client
client requests and server sends abstract data

Flex Data Fundamentals
Three data "paradigm" objects:
- weakly typed
- most basic
- in actionscript
var myobject:ObjectProxy = new ObjectProxy();
myobject.title = "Pocket Symphony";
- in mxml
mx:Model (bonus: you can defined init data with xml)


<>Pocket Symphony<>


mxml has only one root node (album)

pros - you can do whatever you wan, add new properites, don't have to code anything else
cons - your misspellings kill you

- XML (still weakly typed)
in actionscript
var myxml:XML = ; (weird)
you get E4X support "dot" syntax
mytree..treeitem.@label - returns all the labels of tree item nodes at any level in a tree
if you use it, it's harder to migrate to strong typing
- strongly typed
use an actionscript class to formally define the data
{Bindable]
public class Album {
public var title:string;
public var artist:string;
public var tracks:ArrayCollection;
}
To instantiate in ActionScript
var album:Album = new Album();
album.title = 'Pocket Symphony';
In MXML:

Pocket Symphony


flex builder catches problems - compile time validation
- code hinting
- get/set methods

Making data [Bindable] databinding
- every property in this class is now bindable

arrays class is too simple to suppor tdatabinding, but ArrayCollection does support it
ArrayCollection is generically typed in that everything is an Object when it comes out
var item = ac.getItemAt(0);
var item:* = ac.getItemAt(0); // confirm i really want to make this variable typeless
var item:Album = ac.getItemAt(0) as Album; // not 100% safe b/c no guarantee, but it's pretty safe

Flex Services
ways of talking between client and server
RPC servces (http, web, remoteobject)
data management service CRUD, pushing updates, breaking up large results into chunks
FlickrAPI HTTPService cilent proxy
webservice - overhauled
- wsdl (SOAP encoded)
- Data > Import Web Service
remoteObject
- aka flash remoting
- more efficient binary encoding
JSON = crazy alternative to XML serialization
security hole (never eval() JSON in the first place)

RPC service stumbling blocks
make sure to handle faults
implement fault="handleFault(event)" to display errors
function handleResult(event:resultEvent) {...

data management service
- sync collections bwetween colient & server
- resolve confilcts
- push updateds to clients
- handle large results - page results and lazily load related data

dataservice client code

- fill -
- commit
- outside of collections


automagic via servier cahcing of the fill query
to scale turn off
[Managed] on the client classes plus some service config to define relationships

server-side assembler
fill, get, count, sync
or just extend AbstractAssembeler





Robert Reinhart - schematic (flash video guy)
rreinhardt@schematic.com
  • spitemout
  • capture
  • gallery2
  • ffmpeg

No comments: