• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Nick Kwiatkowski - Flex, CF, and LCDS Magic
 

Nick Kwiatkowski - Flex, CF, and LCDS Magic

on

  • 1,142 views

Learn how to use Flex and AIR with LiveCycle Data Services and ColdFusion. We will demonstrate using LCDS’s powerful Data Management features to push data into our Flex application from both ...

Learn how to use Flex and AIR with LiveCycle Data Services and ColdFusion. We will demonstrate using LCDS’s powerful Data Management features to push data into our Flex application from both databases and other sources available to ColdFusion in real time. This session will focus on ActionScript and ColdFusion programming, so intermediate experience in both of these is assumed.

Statistics

Views

Total Views
1,142
Views on SlideShare
1,142
Embed Views
0

Actions

Likes
0
Downloads
17
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Nick Kwiatkowski - Flex, CF, and LCDS Magic Nick Kwiatkowski - Flex, CF, and LCDS Magic Presentation Transcript

    • ColdFusion, LCDS and Flex Magic Nick Kwiatkowski Michigan Flex Users Group & Michigan State University
    • About Me • Manager of the Michigan Flex Users Group • Work at Michigan State University, as a Telecom Manager • Active member of the Flex and ColdFusion communities • Avid mountain biker, general technology evanglist
    • So, magic you say? • What if I told you that after the initial setup, you only had to use 4 lines of code to get data from your application server to your clients? – Sure, we’ve all seen the demo before, but do you really know how it works? » Ok… well, maybe a bit more than 4 lines of code, but well, 4 lines of code sounds sooo easy, you know?
    • The moving parts • ColdFusion – This setup will work with Adobe ColdFusion (sorry, other vendors don’t work out of the box) versioned 7 and above. Version 8+ can have LCDS baked in.*** • LCDS – LiveCycle Data Services is a middleware application designed to move and manage large amounts of data. *** I can’t control what they do with ColdFusion “Next” but one would assume they won’t remove this 
    • The moving parts • Flex – Any version of the Flex SDK over 2.0.0 will work. • Data – Any serializable data, including data from Databases, LDAP, email, FTP, Mapping software, web services, etc.
    • The Convoluted Mess of Stuff™ Browser Java Flex or AJAX application ColdFusion LiveCycle DS Data AIR .NET Application PHP Presentation Layer Business Layer Data-Access Layer
    • The Convoluted Mess of Stuff™ Browser Flex or AJAX application ColdFusion LiveCycle DS Data Presentation Layer Business Layer Data-Access Layer
    • LCDS • But, isn’t LiveCycle Data Services really, really expensive? – Yes, and no. There are three versions of LCDS you need to worry about: • BlazeDS – Open-sourced version of LCDS. Does not include Data Management feature we will be talking about • LiveCycle Data Services ES – J2EE application that Adobe sells that includes all the features of BlazeDS, plus DM, NIO messaging, etc.
    • LCDS – LiveCycle Data Services ES Single-CPU License. (formerly LCDS Express Edition) • Free version of LCDS, that works on 1-CPU, and will not cluster. Can be used for dev, testing and production environments. • Baked right into the ColdFusion 8 download and install. (default is to install it!)
    • Data Management • But, I heard that Flex SDK “Next” will be offering client-side data management! Why should I care about this? – Client-side data management is great for small bits of data, but not much else. – Cannot do things like Data Synchronization, Data Caching, and Conflict Resolution.
    • What LDS brings to the table… • Data Management – Have your application server send large amounts of data to LDS, and let it worry about passing it to the client. This includes pagination of data, and data synchronization. App Server Flex Client LDS
    • What LDS brings to the table… • Data Messaging – Allows Flex clients to communicate with each other without tying up resources on the App server (the App server can participate in these conversations) Flex Client LDS App Server AJAX Client Flex Client
    • What LDS brings to the table… • Data Proxying: – You can proxy your web-service or Remoting calls through your LDS to help get around restrictions in firewalls or policies. Web Service Flex Client LDS App Server
    • DATA MANAGEMENT EXAMPLE
    • Coding The Flex Side • On the Flex side of this setup, there really isn’t a whole lot to do… – Create a new Collection (ArrayCollection) to store your data – Create a value object so that the data serializes properly (you will need to instantiate a copy of this VO, so the compiler includes it) – Utilize the DataService MXML tag, and call the fill(collection) function.
    • CODING A FLEX APP
    • Why it works • Data is packaged up into ‘Value Objects’, or packages of data. – This usually consists of a “row” of data from a database • Each VO is tracked separately as to who is viewing, editing, etc.
    • Why it works • Users then Subscribe to a set of data. – LDS will then keep track of the state of that data, and send it from the Application Server to the Flex Application. • LDS will ‘listen’ to any changes made to the data in the Flex Client.
    • Why it works • If the Collection that holds the data is changed in the client, LDS will take that change, change the Value Object in memory, send the change to the App server, and update all clients in real-time.
    • Why it works • When an update is sent to the other clients, it will check its local copy, to make sure that record has not changed. If it has, it will issue a “Conflict” event, and allow the Client to choose what to do.
    • Why it works • On the Client, 95% of your work is handled by any of the Collection classes, such as the ArrayCollection • Handles updating LDS with Changes, and notifying other visual components of changes.
    • Why it works • When a DataGrid, or InputBox broadcast the Change event, the ArrayCollection hears it, and updates its own data, and passes the change to other components that subscribe to its change event.
    • The “Secret Sauce” • One of the more complicated, and “black box” things about LCDS (and BlazeDS for that matter) is the configuration files. • The config files define two important things: – The Channels – Defines how data flows from the client to the server – The Destination – Defines the ‘namespace’ (think URL) for which the clients are listening.
    • The “Secret Sauce” • Your configuration files are located at : – <ColdFusion Root>wwwrootWEB-INFFlex • The master configuration file is services- config.xml – services-config also holds channel info – messaging-config.xml holds messaging config – data-management-config.xml holds DM config – remoting-config.xml holds Flash Remoting config
    • DIVING INTO THE CONFIGURATION FILES
    • Channels? Destinations? • There are lots of channels to choose from, each with their pluses and minuses. – AMF channels typically run over HTTP, so are often not blocked by firewalls. • Tend to be slower (polling), or designed for one- time polls. • Can be combined with HTTPS for security – RTMP channels run over port 2048 • Real-time, quick, easy. • Firewalls have been known to block on occasion
    • Channels? Destinations? • But don’t worry about choosing only a single channel! You can setup priorities so that your communication can degrade gracefully, but not impact client. – I typically use RTMP -> AMF Polling • Each destination can define which channel(s) it wants to use. • Each destination is just a name – but must be unique to the server.
    • ColdFusion Fun • The final part of this puzzle is the ColdFusion side. While you technically can use just about any AMF powered language (PHP, .NET, Java), why would you? • There are two aspects to the ColdFusion code. – Perform traditional CRUD requests to your data source – Allow un-solisited updates to Flex/LCDS
    • Traditional CRUD • One of the requirements of having LCDS manage your ColdFusion Data, is a CFC that can handle basic CRUD requests. – fill() -- think of this as a “Get all” – get() -- this is to get a single item – sync() -- this performs create, delete, update – count() -- this needs to return the number of records (for paging, etc)
    • Unsolicited Updates • One of the coolest features of LCDS hooked up with ColdFusion and Flex is the fact you can push out unsolicited updates to your clients. – Non-Flex client update data – Customer buys something from your store – update your dashboard – New email comes in.
    • Unsolicited Updates • Creating Unsolicited updates are pretty easy… they involve three steps: – Create a new Event Gateway of type ‘DataManagement’ – Create some sort of Value Object via a structure or CFC. • This structure must serialize the same as your managed data. Use the VO you created for your CRUD operations! – Pass this VO to the Event Gateway. The update will be pushed to your clients.
    • CODING THE COLDFUSION CODE
    • Bringing it all together • So, now we know how it all works, what are some good applications? – CRUD on a database (duh!) – Directory Watcher (dashboard) – Collaborative document management – E-Mail Client with data push – Collaborative GIS Application (spontaneous meetups!)
    • You can reach me at nick@theFlexGroup.org THANK YOU!
    • Obligatory plugs for my peeps • Interested in Flex, and Live in Michigan? – http://www.TheFlexGroup.org – Meets in Lansing, 2nd Thursdays of the Month • Interested in ColdFusion? – http://www.coldFusion.org – Meets in Lansing, 2nd Tuesdays of the Month • Interested in UX – http://www.michiganXD.com – Meets in Grand Rapids, 2nd Tuesday