AdobeStock_455007340

Flex Example: ColdFusion Generated Flex

Home » 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:










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 responses to “Flex Example: ColdFusion Generated Flex”

  1. Dan Cornish Avatar
    Dan Cornish

    OK, this is very impressive. Can you have ColFusion generated HTML and Flex in the same page?

  2. tony weeg Avatar
    tony weeg

    ben,
    is this tapping into my flash player?

  3. tony weeg Avatar
    tony weeg

    or is this some sort of flex server running in the background pushing this out?
    thanks!

  4. tony weeg Avatar
    tony weeg

    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

  5. Ben Forta Avatar
    Ben Forta

    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? πŸ™‚

  6. Igor Ilyinsky Avatar
    Igor Ilyinsky

    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)

  7. Ben Forta Avatar
    Ben Forta

    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!!!! πŸ™‚

  8. chris Avatar
    chris

    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?

  9. pim Avatar
    pim

    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

  10. pim Avatar
    pim

    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/flex/1_5/flexforcf.html. 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

  11. Hem Talreja Avatar
    Hem Talreja

    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.

  12. Ben Forta Avatar
    Ben Forta

    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

  13. George Avatar
    George

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

  14. beijing tour Avatar
    beijing tour

    I have learned sth. thank you very much.

Leave a Reply