Saturday, July 31, 2010    
Home My Books Blog ColdFusion About Me Back    

Calendar
<< Jul 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 31
             

Search

Categories
 • Acrobat (5) [RSS]
 • Adobe (96) [RSS]
 • AdobeMAX06 (45) [RSS]
 • AdobeMAX07 (59) [RSS]
 • AdobeMAX08 (66) [RSS]
 • AdobeMAX09 (39) [RSS]
 • AdobeMAX10 (7) [RSS]
 • AIR (233) [RSS]
 • Appearances (198) [RSS]
 • Books (78) [RSS]
 • CFEclipse (15) [RSS]
 • ColdFusion (1409) [RSS]
 • ColdFusion Builder (9) [RSS]
 • Data Services (36) [RSS]
 • Fish Tank (5) [RSS]
 • Flash (248) [RSS]
 • Flex (513) [RSS]
 • Home Automation (5) [RSS]
 • Jobs (119) [RSS]
 • JRun (14) [RSS]
 • Labs (47) [RSS]
 • LiveCycle (35) [RSS]
 • MAX (238) [RSS]
 • Mobile (138) [RSS]
 • Regular Expressions (18) [RSS]
 • RIA (21) [RSS]
 • SQL (42) [RSS]
 • Stuff (543) [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 12, 2004

Flex Example: ColdFusion Generated Flex

My last Flex blog post demonstrated Flex as a ColdFusion client, a n-tier application using ColdFusion as the logic layer and Flex as the presentation layer. Here is another way to integrate Flex and ColdFusion; dynamically generated Flex.

Click on URL http://www.forta.com:8100/cf/flex/tree.cfm to see an example of a Flex tree. It is a really simple example, and mildly impressive at best. So why am I posting this? Look at the URL, it is a .cfm URL, not a .mxml url.

Christophe Coenraets posted a really useful entry on using the Flex JSP Tag Library so as to be able to generate MXML inline within a JSP page. (See http://www.markme.com/cc/archives/004021.cfm).

Can ColdFusion users do the same? Absolutely, that's exactly what the tree example is doing. ColdFusion can import and invoke JSP tags, and the Flex JSP tags are no exception.

Here is the CFML code used in this example:

<!--- Import Flex JSPs --->
<CFIMPORT TAGLIB="/WEB-INF/lib/flex-bootstrap.jar" PREFIX="mm">

<!--- Create tree XML --->
<CFSAVECONTENT VARIABLE="tree">
<node label='Option 1'>
<node label='Option 1.1'/>
<node label='Option 1.2'/>
</node>
<node label='Option 2'/>
</CFSAVECONTENT>

<!--- Page --->
<HTML>
<BODY>

<H1>Flex Embedded in ColdFusion</H1>

<!--- Start of MXML --->
<mm:mxml>
<mx:Application width="200" height="200" xmlns:mx="http://www.macromedia.com/2003/mxml">
<!--- Tree --->
<mx:XML id="myTree">
<!--- CF tree data --->
<CFOUTPUT>#tree#</CFOUTPUT>
</mx:XML>
<mx:Tree widthFlex="1" heightFlex="1" dataProvider="{myTree}"/>
</mx:Application>
</mm:mxml>

</BODY>
</HTML>

In this example I hard-coded the menu contents to keep things simple, but you can imagine using queries or CFCs or any CFML code here. This type of integration, being able to use both CFML and MXML together, makes it really easy to create ColdFusion/Flex applications.

Comments
OK, this is very impressive. Can you have ColFusion generated HTML and Flex in the same page?
# Posted By Dan Cornish | 1/12/04 6:50 PM
ben,
is this tapping into my flash player?
# Posted By tony weeg | 1/12/04 6:57 PM
or is this some sort of flex server running in the background pushing this out?

thanks!
# Posted By tony weeg | 1/12/04 6:57 PM
alrighty, i know, pardon the idiot, in fact, ben, can you delete these...i see, its the flex bootstrap thing that makes it possible...where does one get this? :) thanks...tony
# Posted By tony weeg | 1/12/04 7:00 PM
Dan, absolutely. That's why I put that H1 tag in there, to show that you can mix HTML and MXML, and of course both can be dynamic CF generated.

Tony, I installed Flex on top of JRun which is also running CFMX6.1. The flex-bootstrap.jar is part of Flex, and exposes the JSP tags which CF uses. There is nothing specific to CF about this, CF kind of gets this for free thanks to its support for JSP tag libraries. It's beautiful when stuff just works, huh? :-)
# Posted By Ben Forta | 1/12/04 8:53 PM
Ben, I think you have hit on a very viable use of FLEX for existing CF developers. A great way to replace CFTREE as so many have asked for. Now, how do you get the data out of that SWF?

Also, you are doing a preso on Flex. Are we allowed to demonstrate flex? or do you have special permission? I want to beat you to presenting Flex for the first time at a UG (just kidding)
# Posted By Igor Ilyinsky | 1/14/04 12:28 PM
Igor, the simplest way to get the data out of the SWF would be SOAP or Flash Remoting.

And no, I am first, so phhhbbbttthhhhh!!!! :-)
# Posted By Ben Forta | 1/18/04 8:25 AM
I realize this is an old post, but have you been able to get the flex user_classes folder to work with cfimport on a CFML page?
# Posted By chris | 4/14/05 2:37 PM
I was reading in this post http://www.newsarch.com/archive/mailinglist/cold-f...
'Not to mention, its very easy to write bad code unintionally when
building Flex MXML widgets embedded in CFML code. If the resultant
MXML changes as per branching logic at runtime, you'd be recompiling
the swf output every time the runtime logic varies, a very expensive
operation.'

If 2 users would meet the same CFIF in a page serving flex conditionaly, will it recompile it every time or will it just output the .swf from the cache?

Kind regards
# Posted By pim | 4/18/05 11:35 AM
Hi,
I can't have your example working, I installed CF7 + Flex 1.5 on Jetty, following the procedure described at http://www.macromedia.com/support/documentation/en.... I can run pure .mxml or pure .cfm but if I try your example, only the H1 tag will output :(
The console throws errors with NoClassDefFoundError :org/apache/axis...
Any idea?
Kind regards
# Posted By pim | 4/19/05 4:53 AM
Dear Ben,

When I try to use the cfimport tag to import the flex-bootstrap.jar file

<!--- Import Flex JSPs --->
<CFIMPORT TAGLIB="/WEB-INF/lib/flex-bootstrap.jar" PREFIX="mm">


I get the following error message.

Could not import the tag library specified by "/WEB-INF/lib/flex-bootstrap.jar".
The following error was encountered: Tag Library Descriptor not found. Please ensure that you have specified a valid tag library.


Note: I'm using CF702 with Flex2.0 on TomCat

The CFML compiler was processing:

* a cfimport tag beginning on line 11, column 2.


where can i find the tag library descriptor for this component.
# Posted By Hem Talreja | 11/24/06 11:15 AM
Hem, this post pertained to Flex 1.5. I've never tried this with Flex 2, but might be doable, but I've not looked into it at all. Sorry.

--- Ben
# Posted By Ben Forta | 11/24/06 11:19 AM
Yes.. it won't work on Flex2.

If you find any workaround on that please let us know, as this is indeed very interesting! :-)

thanks!!
# Posted By George | 11/25/06 5:29 PM
I have learned sth. thank you very much.
# Posted By beijing tour | 7/31/08 4:31 AM

  © Copyright 1997-2009 Ben Forta, All Rights Reserved