Using Flash Forms Inside Of CF 8 Ajax Containers

Posted By : todd sharp Posted At : August 20, 2007 3:58 PM Posted In: Ajax, Flash Forms, ColdFusion

12

A comment on Ray's post about cfgrid renderers today asked why a Flash form grid would not load inside of a cfwindow. I mentioned the reason why Flash Forms/Flex SWF's won't load without modifications previous post, but wanted to throw out a reminder in case folks may have missed it.

When working with Ajax UI elements in CF 8, if your container has any references to external JavaScript libraries they will likely not work. What some folks may not remember offhand is that Flash Forms are dependant on a few external scripts to work their magic, so including those in your main template (the one that calls the cfwindow) will get things to work properly.

Here's a quick conversion of Ray's code to a Flash format grid inside of a cfwindow. Please note that the rendering functionality that Ray blogged about will not work with the Flash grid - it is specific to the Ext grid - but this conversion just shows how it is possible to load a Flash Form in a cfwindow...

index.cfm:

<cfajaximport tags="cfform" />
<script type="text/javascript" src="/CFIDE/scripts/cfform.js"></script>
<script type="text/javascript" src="/CFIDE/scripts/masks.js"></script>
<script type="text/javascript" charset='utf-8' src='/CFIDE/scripts/cfformhistory.js'></script>
<script type="text/javascript" charset='utf-8' src='/CFIDE/scripts/CF_RunActiveContent.js'></script>

<cfwindow name="gridWin" title="grid" initShow="true" closable="true" source="win.cfm" />

win.cfm

<cfset data = queryNew("price,product")>
<cfloop from=1 to=10 index="x">
<cfset total = randRange(20,100) & "." & randRange(1,99)>
<cfset product = "Product #X#">
<cfset queryAddRow(data)>
<cfset querySetCell(data, "price", total+0, x)>
<cfset querySetCell(data, "product", product, x)>
</cfloop>

<cfform name="test" format="flash">
<cfgrid name="data" query="data" width="600">
<cfgridcolumn name="price" header="Price">
<cfgridcolumn name="product" header="Product">
</cfgrid>
</cfform>

Update: As usual - there are issues with IE 7 with this demo. I will revisit...

Comments (12)

Dana Kowalski's Gravatar thanks Todd. I find the v8 livedocs are lacking a lot of interesting tidbits like this one. Hopefully as we progress the comments section will fill up on them with little things like this ;)

Gary Gilbert's Gravatar Hey Todd,

Great example. I never bothered to try and get the flash grid to work within an ajax container I figured the ajax grid was lighter in weight and faster to render than a flash grid.

todd sharp's Gravatar DK: I'm sure they'll fill up shortly :)

Gary: I certainly agree with you - this was really more of a proof of concept.

frank anthony's Gravatar Thanks for the great post. Just wondering if the reverse is possible. Well, not exactly reverse... here is what I like to do. Bind a HTML grid to a flash tabbed form and then use a Ajax submit of the flash form, in a master-detail kind of setup. Of Course all the functions like callback, error message display, grid refresh should happen after the submit. I tried to do this and I am having trouble with the bind. Will this work at all?

Cathy Shapiro's Gravatar Todd, it's great to see someone talking about this! I am trying to load .swf and cfform content into a cflayoutarea (called "lowerrightbox") using the javaScript:ColdFusion.navigate('pageOne.cfm','lowerrightbox')" call from a cfmenu.
Instead of loading the content into the cflayoutarea it loads a new page with just the .swf.
I have tried adding the javascript files (that I know of) to the main page but still have no luck.
Do you know which files I should include to get this content to load?
Thanks for your help!
Cathy

todd sharp's Gravatar Cathy: If you shoot me your code I'd be glad to take a look at it. Email me if you'd like...

Wim's Gravatar Hi Todd, great post.
Any update on the IE7 issues?
I cannot get this to work properly in IE7.

Thanks for the update,
Wim.

Patrick Stewart's Gravatar I copied and pasted the code exactly as above and it doesn't seem to work for me (in IE 6.03). The cfwindow opens and disappears as soon as the form loads. The form replaces the entire page.

Did I miss something?

todd sharp's Gravatar Sorry Patrick, not sure what's up with the IE issues and I've not had the time to revisit this...

Howard Ross's Gravatar I'm trying to put a cfchart in a cfwindow. It works in FF but IE7 throws an error and does not show the chart.

here is code:

index.cfm:

<cfajaximport tags="cfwindow">

<a href="##" onClick="ColdFusion.Window.create('theWindow', 'hasChart','chart.cfm')">Click here</a>

chart.cfm:

<cfchart>
   <cfchartseries type="pie">
   <cfchartdata value="25" item="things">
<cfchartdata value="25" item="stuff">
<cfchartdata value="50" item="shenanigans">
</cfchartseries>
</cfchart>

any suggestions would be much appreciated.

Gavy's Gravatar @ Howard Ross

Hey I would like to point something here.

Don't Go for Flash Forms create a PNG Form and then use cffile action"writetobrowser" to write the chart contents in the window.

use <cfsavecontent to save cfchart contents.

if u stuck anywhere, please drop here or email me

Cheers

Howard Ross's Gravatar @Gavy

I am currently using a work around similar to one you suggest. I use a png type cfchart in a cfc.

I would still prefer to be able to use a flash chart in order to take advantage of it's enhanced interactivity. This is possible in FF so there is most likely a hack to get it to work in IE.

I think you may be refering to cfimage with action="writeToBrowser" although I
'm not sure why that is necessary in this case.

Thanks for help Gavy