Thursday, September 02, 2010    
Home My Books Blog ColdFusion About Me Back    

Calendar
<< Sep 2010 >>
S M T W T F S
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    

Search

Categories
 • Acrobat (5) [RSS]
 • Adobe (97) [RSS]
 • AdobeMAX06 (45) [RSS]
 • AdobeMAX07 (59) [RSS]
 • AdobeMAX08 (66) [RSS]
 • AdobeMAX09 (39) [RSS]
 • AdobeMAX10 (11) [RSS]
 • AIR (236) [RSS]
 • Appearances (200) [RSS]
 • Books (81) [RSS]
 • CFEclipse (15) [RSS]
 • ColdFusion (1418) [RSS]
 • ColdFusion Builder (9) [RSS]
 • Data Services (36) [RSS]
 • Fish Tank (5) [RSS]
 • Flash (259) [RSS]
 • Flex (516) [RSS]
 • Home Automation (5) [RSS]
 • Jobs (120) [RSS]
 • JRun (14) [RSS]
 • Labs (47) [RSS]
 • LiveCycle (35) [RSS]
 • MAX (242) [RSS]
 • Mobile (144) [RSS]
 • Regular Expressions (18) [RSS]
 • RIA (21) [RSS]
 • SQL (42) [RSS]
 • Stuff (544) [RSS]
 • Tips (CF Studio) (80) [RSS]
 • Tips (CF) (795) [RSS]
 • Tips (Dreamweaver) (91) [RSS]
 • Tips (Flex Builder) (2) [RSS]
 • Using CF (164) [RSS]

Other BLOGs
 • Charlie Arehart
 • Lee Brimelow
 • Ray Camden
 • Christophe Coenraets
 • Sean Corfield
 • Mihai Corlan
 • Cornel Creanga
 • Mark Doherty
 • John Dowdell
 • Danny Dura
 • Enrique Duvos
 • Steven Erat
 • Kevin Hoyt
 • Serge Jespers
 • Adam Lehman
 • Duane Nickull
 • Miti Pricope
 • Andrew Shorten
 • Ryan Stewart
 • James Ward
 • Greg Wilson
 • Full As A Goog

RSS Feeds
 • Feed
 • Subscribe

Join my mailing list and find out about new books and other topics of interest.

Thoughts, ideas, tips, musings, and pontifications (not necessarily in that order) by Ben Forta ...
NOTE: This is my personal blog, and the opinions and statements voiced here are my own.

Viewing By Entry / Main
January 2, 2004

Flex App: ColdFusion Resources List

My ColdFusion Resources page lists columns, articles, presentations and more. Over the years the list has grown to the point that the page requires about eight page-down scrolls to see the entire two column list. So, this page seemed like an ideal first Flex app; a tree control showing categories and listings, click to see details of each, and click the link to access the resources.

The new page (powered by Macromedia Flex) is at http://www.forta.com/cf/resources/.

And now for the code:

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
width="600" height="500" initialize="resourceService.GetTreeData()">


<!-- Include query2tree() function -->
<mx:Script source="query2tree.as" />

<!-- Define the service -->
<mx:WebService id="resourceService" wsdl="http://www.forta.com/cf/resources/service.cfc?wsdl" showBusyCursor="true">
<mx:operation name="GetTreeData" />
</mx:WebService>

<!-- Define all bindings -->
<mx:Binding source="query2tree(resourceService.GetTreeData.result)" destination="resourceTree.dataProvider" />
<mx:Binding source="Object(resourceTree.selectedItem.attributes).label" destination="resTitle.text" />
<mx:Binding source="Object(resourceTree.selectedItem.attributes).url" destination="resUrl.label" />
<mx:Binding source="Object(resourceTree.selectedItem.attributes).description" destination="resDesc.text" />

<!-- Title box -->
<mx:VBox verticalGap="0" backgroundColor="#336633" borderStyle="none" widthFlex="1">
<mx:Label text="ColdFusion Resources" color="#FFFFFF" fontSize="20" fontWeight="bold" />
</mx:VBox>

<!-- Body -->
<mx:HBox>

<!--- Resource tree on the left -->
<mx:VBox>
<mx:Tree id="resourceTree"width="250" heightFlex="1" />
</mx:VBox>

<!-- Details on the right -->
<mx:VBox widthFlex="1">
<mx:VBox borderStyle="outset" widthFlex="1" heightFlex="1">
<mx:VBox verticalGap="0" borderStyle="none" widthFlex="1">
<mx:Label id="resTitle" color="#336633" width="330" fontWeight="bold" />
<mx:Link id="resUrl" color="#336633" width="330" click="getURL(resUrl.label, '_blank')" />
</mx:VBox>
<mx:TextArea id="resDesc" widthFlex="1" heightFlex="1" editable="false" wordWrap="true" borderStyle="none" />
</mx:VBox>
</mx:VBox>

</mx:HBox>

</mx:Application>
The code is actually very self-explanatory, but ...

defines the app, and specifies the app size (height and width).

The tag includes an external ActionScript file containing a function that converts returned query data into an XML format needed by the tree control below.

defines the Web Services used, this one points to a ColdFusion Component. This tag does not execute the SOAP call, that is done on startup using the initialize attribute in the tag.

Data bindings are the key to keeping data synchronized between controls. The behavior is a bit like using cell references in Microsoft Excel, once associated with each other, changes in one cell automatically propagate to other cells. The tag takes a source and destination, and ensures that the destination is updated whenever the source changes. The first binding associates the tree control with the results of the GetTreeData SOAP call. The next three bindings associate fields (used to display the title, URL, and description) with whatever is currently selected in the tree control.

The rest of the code is the display. A series of nested boxes (horizontal HBox tags and vertical VBox tags) provide containers for the display. defines the tree control. The right side of the screen contains a control to display the resource title, a control to display a linkable URL, and a control to display the description.

And that is it; 40 lines of code later I have an n-tier application that provides a much better user experience. The back end is the exact same CFC used in the original text version of the page, so no ColdFusion code changes were needed to implement this replacement interface.

Comments
Sorry, I like the old text one better. At least I could see the whole title of the article and use Ctrl-F in my browser.
# Posted By Brian | 1/2/04 5:02 PM
Nice work Ben. But seriously, would you have build this application in Flex if you had to pay a $5000 license? Do you see the problem MM has to face?
# Posted By Jurgen Baumwasser | 1/2/04 5:15 PM
Jurgen - I'm pretty sure Ben just meant this as a nice simple demo app. It's definitely not something you'd need Flex for, but it shows it's power. Flex is really geared for large, multi-developer application development. Those are the people who would pay the hypothetical $5K.
# Posted By Sean Voisen | 1/2/04 6:38 PM
just a queestion: is the %20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 appended at the end of the links on purpose ?
I suppose it isn't it happens only with firebird, not IE ;)
# Posted By Bernard | 1/2/04 6:53 PM
ben,

seems there's a small issue with encoding. in the using xml article there's a bunch of – sprinkled throughout the text body. though nice to see its coming back as unicode!
# Posted By PaulH | 1/3/04 2:23 AM
This is very very cool, thanks for sharing, Ben.

Would it be possible to see the code behind one of those display controls like <mx:VBox>?
# Posted By Jack | 1/3/04 6:44 AM
Brian, the text version is there too.

Jurgen, a) no price has been finalized and announced so I don't know what problems we'll run into just yet, b) I'd not install any product for just this little app, it's an example and a proof of concept, nothing more.

Bernard, thanks for pointing that out, I think you just helped me isolate a bug I have been trying to locate.

Jack, VBox is a built in control, not one of my own, I don't think you can see the MXML for it. However, you can see the ActionScript that the MXML page generates. (MXML->AS->SWF).
# Posted By Ben Forta | 1/3/04 9:37 PM
Fan-tastic! I am chomping at the bit to use Flex.

I noticed all your style is specified in the tags. Have you experimented with using a stylesheet yet?
# Posted By Lara | 1/6/04 11:14 AM
Ben,

seems like there is a bug pretty much at the top of your code

<mx:Script source="query2tree.as" />

should be

<mx:Script src="query2tree.as" />

# Posted By Philipp Cielen | 1/6/04 11:18 PM
We will see how the hypothetical price plays out; I am very interested in trying out flex to replace some of the HTML/Javascript web-based administration tools our company has written. Flex could get quite a bit of traction in this space; a corporate shop can handle the up-front costs, and, if it communicates directly with back-end POJOs and EJBs as transparently as the overview suggests, the savings in developer time will more than make up for it.

Of course, a price tag that high might keep it out of the hands of the hobbyists and independent developers who often come up with the coolest and most creative uses of technology, so Macromedia faces some interesting choices in setting the sticker price. Either way, I am eager to try out replacing the front end of a Struts-based admin webapp with Flex, to see how well it fits for my company. Hopefully next beta round =)
# Posted By Greg | 1/7/04 2:14 PM

  © Copyright 1997-2009 Ben Forta, All Rights Reserved