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:










Flex Embedded in ColdFusion







#tree#



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.

14 thoughts

  1. 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

  2. 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? 🙂

  3. 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)

  4. 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!!!! 🙂

  5. 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?

  6. I was reading in this post http://www.newsarch.com/archive/mailinglist/cold-fusion/general/msg37053.html
    ‘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

  7. 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.

  8. 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!!

Leave a Reply