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

ColdFusion: Article

Make Your Flash Forms More FLEXible

Like what you can do with Flash Forms? Wish you could do more?

Want to make your Flash forms more FLEXible? Well, now you can! But, is there any point, you say, now that Flex 2 is out and effectively free (if you can make do without FlexBuilder)? Well, if you can go with Flex 2 then do so, but maybe like me, it's currently off limits to you...

Since a bunch of the work I'm doing right now is for Sun Microsystems, it's vital that the application runs on Solaris, and for now there's no sign of FlashPlayer 9, which is required for Flex 2, being near to release. Same goes for Linux and just about every portable device out there.

Assuming that you're not taking the Flex 2 route, read on...

Why don't we start by whetting your appetite? Take a look at Figures 1-4 for some ideas of the additional features available that you can't access directly from Flash Forms.

To use these controls as well as pretty much anything else Flex (version 1.5) has to offer you really need to know about just one thing: the PopUpManager. In Flex it's used to open a new window dynamically on top of the calling application or window.

If you're not already familiar with Flex, I'd suggest you start by looking at Adobe's Flex 1.5 documentation at livedocs.macromedia.com/flex/15/.

Here's the ColdFusion code needed to load the Flex code:

<cfform format="Flash" height="600" width="800" onLoad="initApplication()">
   <cfformitem type="script">
     function initApplication()
     {
       mx.managers.PopUpManager.createPopUp(this, Demo1, false);
     }
   </cfformitem>
</cfform>

As you can see, it's somewhat minimal: Simply a <CFFORM> tag that defines the height and width of my application, and an "onLoad" attribute that calls an embedded function (initApplication) that has a single line of code - the call to the PopUpManager. And that is all! ColdFusion simply provides a wrapper. Everything else is now done in Flex (MXML) code.

The createPopUp function has the following parameters:

  • parent: Movie clip that will be the window's parent. Just use "this" to open as a child of the root flash form.
  • className: Classname of the object that will be created.
    modal: If true, then the user can no longer access any of the application outside of our window until it's closed. Useful, but not needed for our main window.
  • initObj: This lets us set parameters in our MXML file or pass data to it.
  • broadcastOutsideEvents: Boolean value that determines if flash should generate mouseDownOutside events if we click outside of the window. Again, not needed for our examples.
My example opens a non-modal window as a child of the flash form. And the interesting part: the second parameter tells it to load an MXML file: Demo1.mxml. Yes, it loads an MXML file! This is what opens up the world of Flex to us since you can write pretty much anything in the native MXML and simply use it in this manner.

As you can see below, the MXML code for these demos is also very simple. (Note: The code below is simplified; see Listings 1-4 for the full code).

Demo1.mxml (Figure 1)
<mx:Canvas>
<mx:HSlider/>
<mx:HSlider/>
<mx:VSlider/>
</mx:Canvas>

Demo2.mxml (Figure 2)
<mx:Canvas>
<mx:TitleWindow>
<mx:FormItem>
<mx:NumericStepper/>
</mx:FormItem>
<mx:ControlBar>
<mx:Button/>
<mx:Button/>
</mx:ControlBar>
</mx:TitleWindow>
</mx:Canvas>

Demo3.mxml (Figure 3)
<mx:Canvas>
<mx:MediaPlayback/>
<mx:MediaDisplay/>
<mx:MediaController/>
</mx:Canvas>

Okay, so these demos are interesting, but if you're happy with the controls provided by ColdFusion Flash Forms then why bother? Well, if you've ever tried to write anything larger than a few forms, then chances are you've run into the dreaded 32k or 64k limit error. Build your applications this way and I doubt you'll see one of those again. Instead of cramming all the different forms and their associated code into a single form, thus rapidly reaching the size limitation, you can put each form into a separate MXML file, each of which has its own size limits. You can effectively build an application as large as you want.

I've built a large application for Sun using this technique. It loads faster than a normal Flash Form, presumably because it doesn't have to process the form tags to build the MXML. It consists of a main page with a tab navigator. Each tab has multiple form elements, and each opens a whole range of different pop-ups, many of which open further pop-ups. I made extensive use of the modal attribute of the createPopUp function since this means I don't have to worry about the user accessing anything but the topmost window.

If you have access to FlexBuilder then you have the added benefit of being able to build your forms visually, which is a welcome relief after fiddling for hours with CF tags to get the layouts just right.

A word of warning: take small steps! The compiler will warn you about some errors, but mostly you'll just get a blank screen if you have something wrong. Check the logs and you're unlikely to find anything more useful than a Java null pointer error.

You'll want to edit the flex-config.xml file on your development machine to give you as much debugging information as possible (typically located at C:\CFusionMX7\wwwroot\WEB-INF\cfform\flex-config.xml). Locate and change the values listed below, then restart the ColdFusion service.

show-all-warnings : true
show-binding-warnings : true

While you're editing this file, two other items of interest are:

  • accessible: If set to true generates screen reader accessible flash forms. This adds about 64k to the size of the final generated SWF file.
  • global-css-url: Tells the compiler where to find the CSS file, which is used to determine how your forms will look. I set mine to "/global.css," which means it looks for a global.css file in the root of my Web server (thus allowing different CSS for each Web site on the server).
You can set default attributes for each of the controls and containers available to Flex, as well as setup styles that can be applied to individual controls via the "styleName" attribute present on all of these. See Listing 5 for a sample CSS file.

Hopefully simply discovering that you can use the PopUpManager to load native Flex has set your minds to thinking about all the things you can now achieve. I'm going to show you one more example showing a simple form with a modal pop-up. I'll show you how to pass a data structure back and forth, and also show you a way around a well-known Flex bug.

We start with a simple form that shows three fields and an edit button (note: The CSS file listed in Listing 5 has been used to style this form). Figure 5 shows our example page, and Figure 6 shows a popup form to edit the details.

As you can see in Listing 6, the three text fields are bound to values in userObj, the data that's initialized in the function initData() that's called when the form loads. When you click the edit button, this code is run:

mx.managers.PopUpManager.createPopUp(this, UserEditForm, true,{parentref:this,userobject:userObj});

This opens our pop-up form (userEditForm.mxml - see Figure 6 and Listing 7) as a modal window. It also passes two pieces of data to our new window: parentref, which allows the pop-up to communicate back to our main form, and userobject, the object containing our user data. Also note the function setUserData() that our pop-up window will use to send the edited data back to the main form. This is defined as a public function, not private like our other (internal) functions.

As with the main form, the TextInput controls' values are bound to the data object, this time to userobject, which was passed from the parent form:

<mx:TextInput id="namefield" text="{userobject.name}" />

Looking at the function saveUser you'll notice that we validate before saving (Figure 6 shows that our form input values are not validated!) by making this call:

if (mx.validators.Validator.isStructureValid(this,'userdata'))


More Stories By Ian Bale

Ian Bale is co-director of Celtic Internet ltd. (www.celticinternet.com), a UK-based software engineering and consultancy company. Ian has worked as a consultant since 1989 in both the telecom and Internet industries.

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
Pim 11/21/06 06:53:17 PM EST

I was wondering one thing, when you use flash forms and submit data to another cfm page, values are accessible as if they were normal forms (form.firstname, form.address ...), what happens in this case ? Would you have to use remoting to submit them ?
Regards,
Pim

Fritz Dimmel 11/21/06 09:19:26 AM EST

Hi!
This article is really, really great! The possiblity of using MXML files in flash forms is unbelievable!
Why didn't you write this article one year earlier? :-) We could have used it really!

Thanks,
Fritz

@ThingsExpo Stories
DX World EXPO, LLC, a Lighthouse Point, Florida-based startup trade show producer and the creator of "DXWorldEXPO® - Digital Transformation Conference & Expo" has announced its executive management team. The team is headed by Levent Selamoglu, who has been named CEO. "Now is the time for a truly global DX event, to bring together the leading minds from the technology world in a conversation about Digital Transformation," he said in making the announcement.
"Space Monkey by Vivent Smart Home is a product that is a distributed cloud-based edge storage network. Vivent Smart Home, our parent company, is a smart home provider that places a lot of hard drives across homes in North America," explained JT Olds, Director of Engineering, and Brandon Crowfeather, Product Manager, at Vivint Smart Home, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
SYS-CON Events announced today that Conference Guru has been named “Media Sponsor” of the 22nd International Cloud Expo, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. A valuable conference experience generates new contacts, sales leads, potential strategic partners and potential investors; helps gather competitive intelligence and even provides inspiration for new products and services. Conference Guru works with conference organizers to pass great deals to gre...
The Internet of Things will challenge the status quo of how IT and development organizations operate. Or will it? Certainly the fog layer of IoT requires special insights about data ontology, security and transactional integrity. But the developmental challenges are the same: People, Process and Platform. In his session at @ThingsExpo, Craig Sproule, CEO of Metavine, demonstrated how to move beyond today's coding paradigm and shared the must-have mindsets for removing complexity from the develop...
In his Opening Keynote at 21st Cloud Expo, John Considine, General Manager of IBM Cloud Infrastructure, led attendees through the exciting evolution of the cloud. He looked at this major disruption from the perspective of technology, business models, and what this means for enterprises of all sizes. John Considine is General Manager of Cloud Infrastructure Services at IBM. In that role he is responsible for leading IBM’s public cloud infrastructure including strategy, development, and offering m...
"Evatronix provides design services to companies that need to integrate the IoT technology in their products but they don't necessarily have the expertise, knowledge and design team to do so," explained Adam Morawiec, VP of Business Development at Evatronix, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
To get the most out of their data, successful companies are not focusing on queries and data lakes, they are actively integrating analytics into their operations with a data-first application development approach. Real-time adjustments to improve revenues, reduce costs, or mitigate risk rely on applications that minimize latency on a variety of data sources. In his session at @BigDataExpo, Jack Norris, Senior Vice President, Data and Applications at MapR Technologies, reviewed best practices to ...
Widespread fragmentation is stalling the growth of the IIoT and making it difficult for partners to work together. The number of software platforms, apps, hardware and connectivity standards is creating paralysis among businesses that are afraid of being locked into a solution. EdgeX Foundry is unifying the community around a common IoT edge framework and an ecosystem of interoperable components.
Large industrial manufacturing organizations are adopting the agile principles of cloud software companies. The industrial manufacturing development process has not scaled over time. Now that design CAD teams are geographically distributed, centralizing their work is key. With large multi-gigabyte projects, outdated tools have stifled industrial team agility, time-to-market milestones, and impacted P&L stakeholders.
"Akvelon is a software development company and we also provide consultancy services to folks who are looking to scale or accelerate their engineering roadmaps," explained Jeremiah Mothersell, Marketing Manager at Akvelon, 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.
"IBM is really all in on blockchain. We take a look at sort of the history of blockchain ledger technologies. It started out with bitcoin, Ethereum, and IBM evaluated these particular blockchain technologies and found they were anonymous and permissionless and that many companies were looking for permissioned blockchain," stated René Bostic, Technical VP of the IBM Cloud Unit in North America, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Conventi...
In his session at 21st Cloud Expo, Carl J. Levine, Senior Technical Evangelist for NS1, will objectively discuss how DNS is used to solve Digital Transformation challenges in large SaaS applications, CDNs, AdTech platforms, and other demanding use cases. Carl J. Levine is the Senior Technical Evangelist for NS1. A veteran of the Internet Infrastructure space, he has over a decade of experience with startups, networking protocols and Internet infrastructure, combined with the unique ability to it...
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 ...
"Cloud Academy is an enterprise training platform for the cloud, specifically public clouds. We offer guided learning experiences on AWS, Azure, Google Cloud and all the surrounding methodologies and technologies that you need to know and your teams need to know in order to leverage the full benefits of the cloud," explained Alex Brower, VP of Marketing at Cloud Academy, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clar...
Gemini is Yahoo’s native and search advertising platform. To ensure the quality of a complex distributed system that spans multiple products and components and across various desktop websites and mobile app and web experiences – both Yahoo owned and operated and third-party syndication (supply), with complex interaction with more than a billion users and numerous advertisers globally (demand) – it becomes imperative to automate a set of end-to-end tests 24x7 to detect bugs and regression. In th...
"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.
Coca-Cola’s Google powered digital signage system lays the groundwork for a more valuable connection between Coke and its customers. Digital signs pair software with high-resolution displays so that a message can be changed instantly based on what the operator wants to communicate or sell. In their Day 3 Keynote at 21st Cloud Expo, Greg Chambers, Global Group Director, Digital Innovation, Coca-Cola, and Vidya Nagarajan, a Senior Product Manager at Google, discussed how from store operations and ...
"There's plenty of bandwidth out there but it's never in the right place. So what Cedexis does is uses data to work out the best pathways to get data from the origin to the person who wants to get it," explained Simon Jones, Evangelist and Head of Marketing at Cedexis, 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.
SYS-CON Events announced today that CrowdReviews.com has been named “Media Sponsor” of SYS-CON's 22nd International Cloud Expo, which will take place on June 5–7, 2018, at the Javits Center in New York City, NY. CrowdReviews.com is a transparent online platform for determining which products and services are the best based on the opinion of the crowd. The crowd consists of Internet users that have experienced products and services first-hand and have an interest in letting other potential buye...
SYS-CON Events announced today that Telecom Reseller has been named “Media Sponsor” of SYS-CON's 22nd International Cloud Expo, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. Telecom Reseller reports on Unified Communications, UCaaS, BPaaS for enterprise and SMBs. They report extensively on both customer premises based solutions such as IP-PBX as well as cloud based and hosted platforms.