Comments
Richard Davies wrote: The UK has a good crop of technology pioneers in cloud computing - for example ElasticHosts, FlexiScale, Flexiant, OnApp - and also some strong government initiatives such as G-Cloud. We will have to see whether this kind of technical leadership converts into swift mass-market adoption or not.
Cloud Computing
Conference & Expo
November 2-4, 2009 NYC
Register Today and SAVE !..

2008 West
DIAMOND SPONSOR:
Data Direct
SOA, WOA and Cloud Computing: The New Frontier for Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
GOLD SPONSORS:
Appsense
User Environment Management – The Third Layer of the Desktop
Cordys
Cloud Computing for Business Agility
EMC
CMIS: A Multi-Vendor Proposal for a Service-Based Content Management Interoperability Standard
Freedom OSS
Practical SOA” Max Yankelevich
Intel
Architecting an Enterprise Service Router (ESR) – A Cost-Effective Way to Scale SOA Across the Enterprise
Sensedia
Return on Assests: Bringing Visibility to your SOA Strategy
Symantec
Managing Hybrid Endpoint Environments
VMWare
Game-Changing Technology for Enterprise Clouds and Applications
Click For 2008 West
Event Webcasts

2008 West
PLATINUM SPONSORS:
Appcelerator
Get ‘Rich’ Quick: Rapid Prototyping for RIA with ZERO Server Code
Keynote Systems
Designing for and Managing Performance in the New Frontier of Rich Internet Applications
GOLD SPONSORS:
ICEsoft
How Can AJAX Improve Homeland Security?
Isomorphic
Beyond Widgets: What a RIA Platform Should Offer
Oracle
REAs: Rich Enterprise Applications
Click For 2008 Event Webcasts
In many cases, the end of the year gives you time to step back and take stock of the last 12 months. This is when many of us take a hard look at what worked and what did not, complete performance reviews, and formulate plans for the coming year. For me, it is all of those things plus a time when I u...
SYS-CON.TV
Developing Flex-Based Rich Internet Applications
A Peek at Data Structures

Since a Rich Internet Application is not a stateless client, you typically have a lot of data in the client, especially when you load dynamically over time. Often, while developing Flex applications, you might need to peek at data structures during runtime‹this is where my utility, the Flex Trace Panel, comes in handy.

Requirements
To make this most of this tutorial, you need to install the following software and files:

Prerequisite Knowledge
This article assumes that you are familiar with the basics of Flex.

The Problem
When you debug a web application that uses HTML in the presentation tier, you typically write debug messages to the either the standard log file of your application server or directly into the HTML output to track the flow of your application or to inspect data. For Flex-powered applications you can leverage the Flex Debugger integrated in Flex Builder 1.5 to inspect your application. However, there are situations were you do not want to run your application under the debugger or inside Flex Builder 1.5 but directly in the browser. In those cases you must use the trace() function or add some sort of sophisticated debug text area to the application to output debug messages.

While the trace() statement works fine for simple debugging tasks, one major drawback of it is that there is no console window to display the messages. Instead, you must browse your local machine for the log file that Flash Player writes to when executing a trace() statement. This may not even work at all if you haven't installed the Flash Debug Player and configured it to enable file logging. Finally, to get some sort of real-time logging experience you must open the log file with some text editor that automatically reloads the file after its content change.

One other technique is to add a logging console to the application itself. This may work, but can compromise the design of your application's user interface.

Introducing the Flex Trace Panel
To improve the debugging experience, I wrote a simple but powerful add-on for your daily Flex development needs: the Flex Trace Panel. It's a standalone application that runs outside the browser and listens for debug messages sent from your Flex application. Received messages display in real time. There are several features such as different log levels and nested object introspection that help you develop and debug your Flex application. Technically, the Flex Trace Panel is a SWF file made with Macromedia Flash Professional 8, wrapped into a stand-alone shell by using the third-party tool Zinc v2.5 by Multimedia Limited.

Once you start the Flex Trace Panel, it creates a new LocalConnection instance and listens for incoming messages. After the Flex Trace Panel receives a message, it writes the data to the output text area. If the data is complex (such as an object), the Trace Panel recursively introspects the structure and prints the hierarchy while avoiding cyclical references that could cause the Trace Panel to freeze. In short, your Flex applications send data to the Flex Trace Panel by using the Dumper class, an ActionScript 2.0 class that comes with the Flex Trace Panel download in the Requirements section.

Using the Flex Trace Panel
To use the Flex Trace Panel, unzip the downloaded ZIP file to a directory of your choice. The directory contains an src and a bin folder, with the Flex Trace Panelexecutable in the bin Folder. You may want to copy this file to another location on your machine.

The src folder contains a directory structure for the Dumper class. Copy the contents of the src folder to your Flex server, so that the Dumper class is available to your Flex application. In general, place the Dumper class in the class path of your Flex application. To make the Dumper class available to all of your Flex applications (recommended for a testing or development system) simply copy the directory structure to the user_classes directory of your Flex server. With a default, out-of-the-box Flex 1.5 installation, this is at:

C:\ProgramFiles\Macromedia\Flex\jrun4\servers\default\flex\WEB-INF\flex\user_classes

If you only want to use the Dumper class in a single application, copy the de.richinternet.utils.* package to the root of your Flex application. After you install the source files, it's time to start the show.

Create a new Flex application and add the following code:


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">
<mx:Script>
<![CDATA[
import de.richinternet.utils.Dumper;

private function sayHello():Void {
Dumper.dump(³Hello World!");
}
]]>
</mx:Script>
<mx:Button label="Say Hello!" click="sayHello()"/> </mx:Application>
Start the Flex Trace Panel and run your Flex application. When you click the button, the following message will appear in the output window (see Figure 1).

The [INFO] text printed left to the message indicates the log level of the message, while (String) tells you the type of data sent. This is extremely helpful when passing complex data such as Arrays or nested Objects to the Trace Panel (see Figure 2).

As mentioned before, you can set up your applications to send any data type to the Flex Trace Panel. For example, if you want to output the content of the DataProvider attached to the DataGrid myGrid you simply write:

Dumper.dump(myGrid.dataProvider);

The Dumper class provides several methods to send data with different log levels to the Trace Panel. This is convenient if you for example want to indicate whether a certain message is an error message or just simple information. The log levels are:

  • INFO
  • WARN
  • ERROR
Here's a listing of all available methods of the Dumper class:
  • Dumper.dump(message:Object):Void takes the passed Object (any type) and routes it to the Flex Trace Panel with log level INFO
  • Dumper.info(message:Object):Void takes the passed Object (any type) and routes it to the Flex Trace Panel with log level INFO
  • Dumper.warn(message:Object):Void takes the passed Object (any type) and routes it to the Flex Trace Panel with log level WARN
  • Dumper.error(message:Object):Void takes the passed Object (any type) and routes it to the Flex Trace Panel with log level ERROR
To distinguish between messages with different log levels, you can use the Flex Trace Panel to filter messages on their log level. By using the Level menu of the Trace Panel, you can filter all received messages. Internally, the Flex Trace Panel uses a message buffer to filter messages dynamically.

To save the content of the output text field to a text file, click the save icon or select Save from the File menu. To clear the text field, select File > Clear or click the trash can icon.

This article explained how you can use the Flex Trace Panel while you develop Flex applications. As with any other software, the Flex Trace Panel will keep evolving. Especially, I'd like to update it so that it runs with Flex 2 and the new Flex 2 Logging API. Stay tuned on developments with the Flex Trace Panel category on my blog.

About Dirk Eismann
Dirk Eismann is a software engineer at the Hannover, Germany–based software company Herrlich & Ramuschkat where he develops and implements web-based applications. Currently he focuses on Flex application architecture and the integration of Flex applications into Java and .NET environments. Dirk has been working with Flex since it hit the streets and now fluently speaks ActionScript 2.0 and MXML. He is also a Macromedia Certified Instructor for Flex and Flash, and an active contributor to the Flex community. He runs richinternet.blog, a blog dedicated to Flash-powered Internet applications.

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

Since a Rich Internet Application is not a stateless client, you typically have a lot of data in the client, especially when you load dynamically over time. Often, while developing Flex applications, you might need to peek at data structures during runtime - this is where my utility, the Flex Trace Panel, comes in handy.


Your Feedback
SYS-CON Italy News Desk wrote: Since a Rich Internet Application is not a stateless client, you typically have a lot of data in the client, especially when you load dynamically over time. Often, while developing Flex applications, you might need to peek at data structures during runtime - this is where my utility, the Flex Trace Panel, comes in handy.
SOA World Latest Stories
Cloud is a shift from the focus on underlying technology implementation to leveraging existing implementations and further building upon them. Cloud orchestration or a network of clouds is the wave of the future where these clouds can operate with elasticity, scalability, and efficienc...
In Aug 2011, around 72 million people accessed social networking sites from mobile, increase of 37% from previous year (study by ComScore) and nearly 50% (of 72 million) access networking sites almost every day. Devising a cohesive strategy for addressing both mobility and social medi...
Citrix has opened up a beta of its CloudStack 3, the first release of the open source cloud platform under the Citrix brand. Citrix acquired the Java-based cloud management last year when it bought Cloud.com. A full production version of the branded stuff is supposed to be available ...
EMC and VMware are going into the cloud business with Atos, the big, publicly owned, Paris-based global IT services firm, intending to take an equity position in Canopy, an end-to-end cloud company Atos is setting up using EMC and VMware technology. The companies said Wednesday when ...
A Munich court Thursday found Motorola Mobility guilty of infringing an Apple patent and handed Apple a permanent injunction against two Android smartphones. Apple can enforce the injunction after posting a bond lest MMI succeed in invalidating the slide-to-unlock patent (EP1964022) ...
In a surprise move on Tuesday, January 10, Oracle wheeled out its Big Data Appliance. That’s the one it said in October would be ready sometime in the first half. Only nobody believed it meant early in the first half. Heck, it’s not even clear anybody thought Oracle could make the fi...
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


SYS-CON Featured Whitepapers
ADS BY GOOGLE