Ctrl-Z to Undo: Implementing a Transaction Manager in a Rich Internet ApplicationGalen Rileygalenriley@gmail.com@TotallyGreatBarCamp Chattanooga 2009
AgendaHistory of network applicationsDiscuss advantages of RIAsDescribe a transaction managerWrite a simple applicationImplement the transaction manager
Client-Server ApplicationsClient-Server ApplicationsInstalled on each machineCustom network programmingUpdates on the server may require updates on each client
Web ApplicationsExist entirely on a serverWork in a browser – no installation!Easily managed and modified
Rich Internet ApplicationsMore sophisticatedMay require a browser plug-inConsistency across browsersEasy to do client-side executionMedia
RIA FrameworksAdobe FlexMicrosoft SiverlightJavaFXAJAX
Transaction ManagerComplex interactions in a RIABack up in case of a mistakeRIA development lends itself to adding this feature
A Simple Application
A Simple Application
ChecklistStack data structure available anywhere in the program
Singleton Pattern
Using a SingletonTransactionManager.getInstance().doSomething()
ChecklistStack data structure available anywhere in the programClasses to hold state informationCommand design pattern
Transaction Class
ChecklistStack data structure available anywhere in the programClasses to hold state informationCommand design patternMethod of passing messages
TransactionManager classprivatevar _undoStack:Array;privatevar _redoStack:Array;publicfunction addTransaction( transaction:Transaction ) :voidpublic function undo() :voidpublic function redo() :voidDispatch events from here
Using the Transaction ManagerSelect interesting user actionsAdd Transaction objects to the managerListen for TransactionEvent.UNDO and TransactionEvent.REDOUse the Transaction object to roll back the actionAllow the user to Undo and Redo
One Last ThingUndoing an action runs code that modifies the TransactionManager’s stackSolution: Ignore transactions while executing a Undoprivatevar _ignoreOutsideTransactions:Boolean;privatefunction ignoreOutsideUndoTransactions() :voidprivatefunction resumeOutsideUndoTransactions() :void
Advanced FeaturesMultiple levels of undoprivatestaticconst TRANSACTION_LIMIT:int = 10;Batch transactionsBetter UI Integration
Questions?Source code for the transaction manager and sample application are available. Email galenriley@gmail.com

Ctrl+Z To Undo