Welcome!

You will be redirected in 30 seconds or close now.

ColdFusion Authors: Yakov Fain, Jeremy Geelan, Maureen O'Gara, Nancy Y. Nee, Tad Anderson

Related Topics: ColdFusion, Adobe Flex, Machine Learning

ColdFusion: Article

CFDJ Feature — Adobe Flex 2.0 View States & Transitions

How programming got to be fun again

Many ColdFusion developers expressed this sentiment after downloading and working with the Flex 2 beta. Flex 2 has made developing rich Internet applications in the Adobe Flash environment possible for everyone (not just those of us who know and love timelines and tweens).

If you've had the opportunity to experience rich Internet applications developed with Flex 2, you likely need little convincing about its benefits from a user's point-of-view. The concept of rich Internet applications (RIAs) is transforming the way we think about using and developing Web-based applications. However, as developers, many of us are just getting introduced to this concept of rich Internet applications and what they offer users of our applications.

Over the past several months a number of technologies have emerged as candidates for developers to add rich interfaces to browser-based Web applications. Among these technologies, Adobe Flex 2.0 has surfaced as one of the most powerful tools for developers looking to build rich Internet applications. With Flex, Adobe has provided developers with the tools needed to deliver on the promises of RIAs. One of those tools involves the newly introduced concepts of view states and transitions. Let's take a closer look at just what a view state is and how we can use it along with transitions to enhance our applications.

View States
View states are what let Flex developers declare multiple states or views for an application or component. In fact, the Flex documentation defines a view state as simply a particular view of a component. This view can be defined in either the visual or functional capabilities of the component. Every component, or application for that matter, has a default or base state in which we define how the component looks and behaves when it's initialized. From that base state, we can define additional view states by specifying how the component or application changes from its base state, or any other defined state, to the newly created state.

This capability lets our applications have separate states or views based on any number of criteria that we may define. For instance, when developing a classic Web application, we have all had to address requirements to display data differently for different users perhaps depending or their login status and role, the application state, or other external factors such as a deadline passing.

In a classic Web-based application we could approach this problem in a number of different ways using everything from in-line logic to control the display of specific application components to creating entirely separate pages to be included based on the state of the application. View states in Flex let us get this functionality without having to load multiple Flash applications or produce spaghetti logic to control how our application is viewed by a given user or when the application is in a particular state.

In Flex, view states can be created and managed with either MXML tags or ActionScript code. For the sake of this discussion, we'll focus on how MXML tags let us define and use view states. Using MXML, we'd use the <mx:states> and <mx:state> child tags to define named states in our component or application.

You create a new named view state by altering the base state or another view state of a component or application by adding or removing child components, setting application and component properties, styles, and event listeners. Flex builder makes this very convenient since we can create and manage our view states in the design view using the States tab. The code sample shown in Figure 1 provides a basic example of a search interface. An "Advanced Search" view state has been defined to give the user additional search parameters.

In this example code you can see that the "Advanced Search" state is being defined by listing the changes that have to be made to the base state of the application. This code uses the <mx:State> tag to make use of the mx.states class. This class lets us define our state by giving it a name using the name property, specifying the view by which our newly created state is based using the basedOn property.

As is the case in our example, if the basedOn property isn't set, the view will be based on the base state or default view of the component or application. The MXML <mx:AddChild> tag is also used to add and position additional components in our "Advanced Search" view states. It also uses the <mx:SetEventHandler> tag to define event handlers that are active only when their parent's view state is active.

Transitions
Almost anytime you read or hear about view states in Flex 2, transitions can't be far behind. While view states, functionally speaking, are a powerful new feature in Flex 2, transitions are what make them a beautiful new feature.

By default, when we change view states in a Flex 2 application, Flex makes all of the changes at the same time. Visually, it appears like any changes that we've defined in our view state; adding, removing, or resizing components all appear to change instantly as our application jumps from one state to the next. From a usability standpoint, it's much more effective for users to see the changes take place and transitions let us do just that. Using transitions lets us define a smooth visual change as our application changes from one state to the next.

As we have seen with many other powerful features, Flex 2 makes it very easy to implement transitions when switching from one view state to the next. We can do this by using the Transition class to create a transition and then specifying the fromState, toState, and effect properties of the Transition class. The fromState and toState properties simply tell Flex when the transition should be applied and the effect property defines an effect object that tells Flex which effects to play and how they should be played.

The code sample in Figure 2 defines a parallel transition to be applied whenever we change states in an application. Specifying a value of * in the fromState and toState tells Flex to run this transition anytime we change states.

History Management
Another powerful feature of Flex 2 that can be used when defining view states is the Flex HistoryManager class. Many developers have experienced the pain of providing history management by way of the browser's back and forward navigation commands when using alternate RIA development technologies such as AJAX.

Adobe Flex 2 provides access to the Flex HistoryManager class. Registering our application with the HistoryManager class can let our users use their browsers' back and forward navigation commands like they do with traditional browser-based Web applications. Flex does this by letting developers track and save the state of an application each time we change to a new view state. No need for any complicated ActionScript or JavaScript.

With Flex, we can enable history management in our applications via the IHistoryManagerClient interface. Our application can implement this interface by implementing loadState() and saveState() methods. After registering the application with the HistoryManager class, we can call the HistoryManager.save() method every time the application state changes to save the state of the application. The code sample below shows how this can be done. It even remembers to run our transition.

We've seen how view states address a very common requirement when building Web applications by letting developers display data differently to users based on any number of other factors. View states in Flex allow us to do this in an elegant manner that's simple to maintain. Transitions, when coupled with view states, can enhance our applications by using effects to provide a visual indication to our users that the state of our application has changed. Additionally we can use the Flex HistoryManager class to allow our users to use the browsers back and forward navigation commands to navigate our applications. Flex 2 has provided developers with powerful options to deliver next generation Web applications.

Yes! Programming is fun again!

References

  • Adobe Systems Inc. Flex 2.0 Developers Guide. 2006.
  • Adobe Systems Inc. Adobe Flex 2.0 ActionScript and MXML Language Reference. 2006.
  • http://labs.adobe.com

More Stories By Walter Ferguson

Walter Ferguson is a Certified Advanced ColdFusion MX developer.

Comments (2) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
David Betz 08/23/06 04:18:47 PM EDT

The paragraph on the HistoryManager says "The code sample below shows how this can be done." No code sample is provided.

news desk 08/14/06 02:05:52 PM EDT

Many ColdFusion developers expressed this sentiment after downloading and working with the Flex 2 beta. Flex 2 has made developing rich Internet applications in the Adobe Flash environment possible for everyone (not just those of us who know and love timelines and tweens).

@ThingsExpo Stories
Announcing Poland #DigitalTransformation Pavilion
Digital Transformation is much more than a buzzword. The radical shift to digital mechanisms for almost every process is evident across all industries and verticals. This is often especially true in financial services, where the legacy environment is many times unable to keep up with the rapidly shifting demands of the consumer. The constant pressure to provide complete, omnichannel delivery of customer-facing solutions to meet both regulatory and customer demands is putting enormous pressure on...
DXWorldEXPO LLC announced today that All in Mobile, a mobile app development company from Poland, will exhibit at the 22nd International CloudEXPO | DXWorldEXPO. All In Mobile is a mobile app development company from Poland. Since 2014, they maintain passion for developing mobile applications for enterprises and startups worldwide.
CloudEXPO | DXWorldEXPO are the world's most influential, independent events where Cloud Computing was coined and where technology buyers and vendors meet to experience and discuss the big picture of Digital Transformation and all of the strategies, tactics, and tools they need to realize their goals. Sponsors of DXWorldEXPO | CloudEXPO benefit from unmatched branding, profile building and lead generation opportunities.
The best way to leverage your CloudEXPO | DXWorldEXPO presence as a sponsor and exhibitor is to plan your news announcements around our events. The press covering CloudEXPO | DXWorldEXPO will have access to these releases and will amplify your news announcements. More than two dozen Cloud companies either set deals at our shows or have announced their mergers and acquisitions at CloudEXPO. Product announcements during our show provide your company with the most reach through our targeted audienc...
@DevOpsSummit at Cloud Expo, taking place November 12-13 in New York City, NY, is co-located with 22nd international CloudEXPO | first international DXWorldEXPO and will feature technical sessions from a rock star conference faculty and the leading industry players in the world.
Everything run by electricity will eventually be connected to the Internet. Get ahead of the Internet of Things revolution. In his session at @ThingsExpo, Akvelon expert and IoT industry leader Sergey Grebnov provided an educational dive into the world of managing your home, workplace and all the devices they contain with the power of machine-based AI and intelligent Bot services for a completely streamlined experience.
DXWorldEXPO | CloudEXPO are the world's most influential, independent events where Cloud Computing was coined and where technology buyers and vendors meet to experience and discuss the big picture of Digital Transformation and all of the strategies, tactics, and tools they need to realize their goals. Sponsors of DXWorldEXPO | CloudEXPO benefit from unmatched branding, profile building and lead generation opportunities.
22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud ...
In his keynote at 19th Cloud Expo, Sheng Liang, co-founder and CEO of Rancher Labs, discussed the technological advances and new business opportunities created by the rapid adoption of containers. With the success of Amazon Web Services (AWS) and various open source technologies used to build private clouds, cloud computing has become an essential component of IT strategy. However, users continue to face challenges in implementing clouds, as older technologies evolve and newer ones like Docker c...
"MobiDev is a software development company and we do complex, custom software development for everybody from entrepreneurs to large enterprises," explained Alan Winters, U.S. Head of Business Development at MobiDev, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
JETRO showcased Japan Digital Transformation Pavilion at SYS-CON's 21st International Cloud Expo® at the Santa Clara Convention Center in Santa Clara, CA. The Japan External Trade Organization (JETRO) is a non-profit organization that provides business support services to companies expanding to Japan. With the support of JETRO's dedicated staff, clients can incorporate their business; receive visa, immigration, and HR support; find dedicated office space; identify local government subsidies; get...
Dion Hinchcliffe is an internationally recognized digital expert, bestselling book author, frequent keynote speaker, analyst, futurist, and transformation expert based in Washington, DC. He is currently Chief Strategy Officer at the industry-leading digital strategy and online community solutions firm, 7Summits.
Bill Schmarzo, author of "Big Data: Understanding How Data Powers Big Business" and "Big Data MBA: Driving Business Strategies with Data Science," is responsible for setting the strategy and defining the Big Data service offerings and capabilities for EMC Global Services Big Data Practice. As the CTO for the Big Data Practice, he is responsible for working with organizations to help them identify where and how to start their big data journeys. He's written several white papers, is an avid blogge...
In past @ThingsExpo presentations, Joseph di Paolantonio has explored how various Internet of Things (IoT) and data management and analytics (DMA) solution spaces will come together as sensor analytics ecosystems. This year, in his session at @ThingsExpo, Joseph di Paolantonio from DataArchon, added the numerous Transportation areas, from autonomous vehicles to “Uber for containers.” While IoT data in any one area of Transportation will have a huge impact in that area, combining sensor analytic...
Bill Schmarzo, author of "Big Data: Understanding How Data Powers Big Business" and "Big Data MBA: Driving Business Strategies with Data Science," is responsible for setting the strategy and defining the Big Data service offerings and capabilities for EMC Global Services Big Data Practice. As the CTO for the Big Data Practice, he is responsible for working with organizations to help them identify where and how to start their big data journeys. He's written several white papers, is an avid blogge...
Charles Araujo is an industry analyst, internationally recognized authority on the Digital Enterprise and author of The Quantum Age of IT: Why Everything You Know About IT is About to Change. As Principal Analyst with Intellyx, he writes, speaks and advises organizations on how to navigate through this time of disruption. He is also the founder of The Institute for Digital Transformation and a sought after keynote speaker. He has been a regular contributor to both InformationWeek and CIO Insight...
Michael Maximilien, better known as max or Dr. Max, is a computer scientist with IBM. At IBM Research Triangle Park, he was a principal engineer for the worldwide industry point-of-sale standard: JavaPOS. At IBM Research, some highlights include pioneering research on semantic Web services, mashups, and cloud computing, and platform-as-a-service. He joined the IBM Cloud Labs in 2014 and works closely with Pivotal Inc., to help make the Cloud Found the best PaaS.
It is of utmost importance for the future success of WebRTC to ensure that interoperability is operational between web browsers and any WebRTC-compliant client. To be guaranteed as operational and effective, interoperability must be tested extensively by establishing WebRTC data and media connections between different web browsers running on different devices and operating systems. In his session at WebRTC Summit at @ThingsExpo, Dr. Alex Gouaillard, CEO and Founder of CoSMo Software, presented ...
I think DevOps is now a rambunctious teenager - it's starting to get a mind of its own, wanting to get its own things but it still needs some adult supervision," explained Thomas Hooker, VP of marketing at CollabNet, in this SYS-CON.tv interview at DevOps Summit at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.