Our Blog

We had given for granted that it was not possible to use Flash Remoting with ColdFusion Flash Forms because of the ActionScript language restrictions that they have. All workarounds used external .swf loaded into the form, so we never used them and we never investigated any further. Otherwise, we would’ve found that there is a simple way to get remoting in ColdFusion Flash Forms sooner. In any case, here it is, better late than never. Note that this does not use external swf and therefore it is not a hack.

As an introduction, we made a simple example in which we call a cfc that returns a formatted string according to the parameter passed.

<cfsavecontent variable="getData"> //create connection, replacing the gateway url with yours var connection:mx.remoting.Connection = mx.remoting.NetServices.createGatewayConnection( &amp;quot;http://www.example.com/flashservices/gateway/&amp;quot;); //declare service var myService:mx.remoting.NetServiceProxy; //put the controls in scope to avoid calling _root var mask = mask; var display = display; //make an object that will handle the response var responseHandler = {}; //function that receives the response responseHandler.onResult = function( results: Object ):Void { //when results are back, we show the text received display.text = results; } //function that receives any error that may have occurred during the call responseHandler.onStatus = function( stat: Object ):Void { //if there is any error, show an alert alert(&amp;quot;Error while calling cfc:&amp;quot; + stat.description); } //get service. First parameter is path to component and the second it&#39;s the object that will handle the response myService = connection.getService(&amp;quot;blog.examples.flashRemotingResponder&amp;quot;, responseHandler ); //make call, passing one parameter myService.getDate(mask.text); </cfsavecontent> <!--- then the form ---> <cfform format="Flash" name="myform"> <cftextarea label="Mask" name="mask" type="text">mmmm dd of yyyy hh:mm:ss</cftextarea> <cfinput label="Result" name="display" type="text"> <cfinput name="getDataBtn" onclick="#getData#" type="Button" value="Get Date"> </cfinput></cfinput></cfform>

This is what the cfc does, as you can see it’s a very simple function.

<cffunction access="remote" description="Returns the current time" name="getDate" output="false" returntype="string"> <cfargument default="" name="mask" required="false" type="string"> <!--- get the current time ---> <cfset time="now()" var=""> <cfif> <!--- format the date according to mask ---> <cfset time="dateformat(time,arguments.mask)"> </cfset></cfif> <cfreturn time=""> </cfreturn></cfset></cfargument></cffunction>

A live example
Download the source

A couple of notes on Remoting:
The component that you call has to be web accessible for the Remoting gateway to find it, just like when you create a web service, and the method has to have access="remote".

The path to the component is the directory structure as viewed from the root of your website, separated by dots, followed by the component name. For example, if your component is located at http://www.example.com/somedir/components/myComponent.cfc, then the path would be somedir.components.myComponent

That being said, I never have my components in the root of my website, but in a mapping called com, where I have directories with the names of my domains. I then call my components com.blueinstant.somepackage.myComponent

This, however, won’t work with remoting, so what I do is create a façade component that exposes only the methods that flash needs, and can even format the data specifically for flash, separating this from my other components that know nothing about the views. In addition, from that component I can enforce security or call an already instantiated object that I keep in a shared scope.

Lastly, the documentation warns that Application.cfc should not implement the “onRequest” method if we have “any CFC files that are intended to be accessed as web services, using Flash Remoting, or using an event gateway”

Laura

Laura

128 Comments

  1. Brian Sloan

    Brian Sloan

    Where is the flashservices directory supposed to be? It looks like it is supposed to be in the wwwroot directory from the cgi.http_host var in the download. Also, does CF come with flashservices or do I need to download it from macromedia?
  2. Brian Sloan

    Brian Sloan

    Nevermind... It seems to work as is. I just tested it out on our server and it worked great. Thanks, this is going to make life way easier. Currently I have screens with 2 grids and the 2nd is dependent on the first. Before this I had to execute both queries and save the 2nd grids in a global var then clear it.
  3. Philippe

    Philippe

    So, mx.remoting.Connection comes from the Flex packages, right?
  4. Brian Sloan

    Brian Sloan

    There seems to be a couple of problems implementing this with my app.

    1. Does the cfc have to be in the root of site? It appears it does and all mine are under a components directory. Is there any way around this or do I have to put the cfc in the root?

    2. If my application.cfc file is present I get an event handler exception. It appears something in it is stopping the flash remoting from working. Any ideas or solutions to this problem? I need the application.cfc for security reasons.
  5. Steve Walker
    Brian,

    I don't know if this will help in your scenario, but I point to my components in the Application.cfc file (e.g. &lt;cfset Request.libcfc = root.folder.file&gt;) and then using their example :
    myService = connection.getService(&quot;&lt;cfoutput&gt;#REQUEST.libcfc#&lt;/cfoutput&gt;&quot;, responseHandler );

    and everything works fine
  6. Steve Walker
    1. I should clarify. Where I put root.folder.file, root is actually a folder under the root of my domain which is a completely separate website. The dot notation should represent the folder structure of your site (e.g. folder.file).

    2. Is there a way to present an empty grid without using queryNew()? Having to do this sort of defeats the purpose of using reusable components.
  7. Brian Sloan

    Brian Sloan

    Steve,

    Thanks... I will try putting them under a completely different site. As far as I know you need the queryNew at this point for the grid to function. If there is no query= in the grid tag you can not add rows.
  8. Brian Sloan

    Brian Sloan

    Now I am getting some where. Now I have the data populating on the 2nd grid when the 1st grid is clicked. However, I can't seem to manipulate the data now. The filters wont work and without using dataProvider.addItem the grid is undefined so cfgridupdate wont work. Any ideas?

    Thanks,
    Brian
  9. Steve Walker
    Okay, so I saw the updated information that says not to use the onRequest method. The CF7 documentation says not to because MX won't process the request. I did use the onRequest method and I do have my cfc buried in my components folder. Everything works fine, so is that a bug, is there something amiss in the documentation, or are there security concerns that aren't addressed?
  10. Todd
    This has to be the coolest thing i've ever seen. One question though, like others, i'm losing all binding capabilities when i use this. Also, I had a tree populated by the same original query that is not working now either....:(
  11. Pedro Claudio

    Pedro Claudio

    Congratulations!
    WebService,HTTPService,RemoteObject
  12. Laura
    Philippe,
    the class mx.remoting.Connection
    is a Flash remoting class, not specifically Flex. It does come with Flex, since Flash Forms use the remoting packages.
    Was that your question?
  13. Todd,
    I don't know why you don't have bindings anymore. I would suggest you to check the column names of your data.
  14. Pedro Claudio

    Pedro Claudio

    I stow to some time making tests as this, now not. I investigated in the WEB-INF/cfform folder the packages to jar and the package swc and what more it called the attention was the package swc for class that they are not in system_classes, as:
    mx.core.*
    mx.charts.*
    mx.Remotig.*
    mx.Service.W*
    mx.Service.*
    mx.servicetags.*
  15. Todd
    Nahuel,

    I'm sure I'm doing something wrong, but bindings are still not working. I thought I'd try your source code since I may have goofed my column names, and still no luck. Here is my code - the only thing I added to your example was the bound text box:

    &lt;cfform name=&quot;myform&quot; height=&quot;350&quot; width=&quot;400&quot; format=&quot;Flash&quot; timeout=&quot;300&quot; &gt;
       &lt;cfgrid name=&quot;contactList&quot; query=&quot;memberList&quot; height=&quot;200&quot; rowheaders=&quot;false&quot;&gt;
             &lt;cfgridcolumn name=&quot;name&quot; header=&quot;Name&quot; /&gt;
             &lt;cfgridcolumn name=&quot;age&quot; header=&quot;Age&quot; /&gt;
             &lt;cfgridcolumn name=&quot;gender&quot; header=&quot;Gender&quot; /&gt;
       &lt;/cfgrid&gt;
       &lt;cfinput type=&quot;button&quot; name=&quot;getValues&quot; value=&quot;Populate data grid&quot; onClick=&quot;#getData#&quot;&gt;
       &lt;cfinput type=&quot;text&quot; name=&quot;test&quot; bind=&quot;{contactList.dataProvider[contactList.selectedIndex]['name']}&quot;&gt;
    &lt;/cfform&gt;

    Thanks for any possible advice you may be able to give. Keep up the amazing work - I really hope you guys are making some money off this - You really deserve it!
  16. Steve Walker
    Todd,

    Try:
    bind=&quot;{(contactList.selectedItem.name ==undefined)?'':contactList.selectedItem.name}&quot;

    It is working for me. The first part ensures that the field is blank instead of the word undefined.
  17. Todd
    now THAT works....thanks Steve - you're the man!
  18. Paul Roe

    Paul Roe

    I am just running CFMX7.0 can I make use of Flash Remoting or do I need to buy Flex or the actual Flash Remoting product that MM sells?
  19. Hi Paul,
    You don't need to buy anything. ColdFusion already comes with Remoting :)
  20. Paul Roe

    Paul Roe

    Well then what do I have to configure to get this working. I get the following errors:

    Error /CFIDE/scripts/cfform.swc
    Unable to resolve library location.

    Error /cfgrid-remoting.cfm:4
    Unable to load runtime shared libraries.

    Does Flash remoting require any setup?
  21. Laura
    Paul,
    Remoting setup is not the problem, at least not yet. Your Flash forms do not work because you don't have the cfide folder web accessible. You can either copy the CFIDE folder (without the administrator if you don't need it) to your web root or make a virtual directory pointing to it.

    Hope that helps
  22. Paul Roe

    Paul Roe

    Thanks for the help so far guys, but I'm still having issues. If you have it in you to help me further, please email me at paul (dot) roe (at) gmail (dot) com.
  23. CarlosM()

    CarlosM()

    This is exactly what I've been waiting for MM to do in its’ next release! NO NEED to wait now...

    OK, here’s my question….

    I'm running CFMX7 Standard w/Apache2 on Suse9ENT , can I still do the remoting or do I need CFMX7Ent running on a Java Server???

    Now I was able to get:
    CFMX7ENT .WAR running with TomCat4 with the Apache hook on SuSe9Ent but I had problems with the RDS so I went back to the CF Standard Edition. Is this going to haunt me?
  24. CarlosM()

    CarlosM()

    It works in CFMX7 Standard! I got the grid to populate with my own query in a CFC.

    Isn't it great when thing just work.

    Ok, I hope I'm not asking too much but is it possible to create a custom tag for this?
  25. Marcus,
    Yes, you can pass as many as you want.

    Carlos,
    We'll add that to the wish list :)
  26. Neil Bailey
    I am sure this is a newbie question (as I am a 'remoting' newbie), but its literally killing me. I am to call the CFC, no problem. I can get the results back, no problem. But the CFC is returning a struct, and we want to take that data and return it to multiple fields.

    Also, the object that gets passed into onResults - I can't find ANYTHING on this object. Does anyone know where I can see soms docs on this?
  27. Neil,
    These are the docs
    http://livedocs.macromedia.com/flashremoting/mx2004/index.html

  28. Neil Bailey
    Nahuel,

    Thanks - I actually managed to figure this out, too (this one on my own!) Actionscript won't take a structure back (at least according to the docs), but it WILL take an array. So, I got it straightened out. Thank you again for your help, and keep up the good work.
  29. Marcus
    Nahuel, can you give me an example of how to send multiple parameters?

    Thx
  30. Marcus
    Nahuel: Please disregard my previous post, I'm an idiot for not looking at the live docs.

    Marcus
  31. Laura
    Neil,
    ActionScript does take structures back. We use it all the time. In fact, we use it the MXNA application (check mxna.cfc for example). All of the functions there return structures, not plain queries. The problem you must have had is the case in the structure. When you create a structure and set up the keys as myStruct.key1, CF will make it uppercase, myStruct.KEY1. Because ActionScript is case sensitive, it will not find it.
    In order to keep your desired case, you must create your structure keys as
    &lt;cfset myStruct[&quot;key1&quot;] = &quot;&quot; /&gt;
    &lt;cfset myStruct[&quot;msg&quot;] = &quot;&quot; /&gt;

    and so on.
  32. Kola
    Guys
    I've really just started putting flash forms through their paces (while learning flash at the same time). Question I have is does anyone envisage this being disabled in anyway in one of the new releases? I imagine that MM didn't really want cfdevelopers to be able to utilise remoting in this way and would rather we all use flash?
  33. Neil Bailey
    Thanks, Laura, I am going to go through that now! In the meantime, another question (hopefully the last one). Can I (quickly and easily) pass the entire form to a CFC, or do I need to specify each field, one value at a time?
  34. Neil Bailey
    Laura,

    I am literally pulling my hair out here! I simply cannot get the actionscript code in the main page to see the values returned in a structure.... I created the struct in the CFC as you suggested above, and at this point........ haha I'm sure you've been at this point once or twice..

    responseHandler.onResult = function( results: Object ):Void {
       //when results are back, populate the data fields
       _root.first_name.text = results.first_name;
       }

    PLEASE let me know what I am doing wrong here.....
  35. Liz
    What is the correct syntax to get the query result set from the responseHandler?

    I currently call my myservice.getProduct ({spc_product_code_id:oi_product1.value}) which should return a row of data. This is my component function:
    &lt;cffunction name=&quot;getProduct&quot; output=&quot;Yes&quot; returntype=Query access=&quot;remote&quot;&gt;
    &lt;cfargument name=&quot;spc_product_code_id&quot; type=&quot;String&quot; required=&quot;True&quot;&gt;
    &lt;cfquery name=&quot;getdata&quot; datasource='#DataBse#' timeout='30'&gt;
       select SPC_PRODUCT_CODE_ID,
          SPC_PRODUCT_NAME,
          SPC_UNIT_PRICE_MN,
          SPC_ACCTG_CODE_ID
        from T_SUPP_PRODUCT_CODES WITH (NOLOCK)
        where SPC_PRODUCT_CODE_ID = #val(spc_product_code_id)#
       Order by SPC_PRODUCT_NAME
    &lt;/cfquery&gt;
    &lt;cfreturn getdata&gt;   
    &lt;/cffunction&gt;
    (The query works fine non-remotely.)
    However, when I try to access the results from the responseHandler I get garbage displayed in my oi_price1.text display field.

    responseHandler.onResult = function( results: Object ):Void {
    oi_price1.text = results.spc_unit_price_mn;
    }

    What is the correct syntax to access the data returned in the results variable? Please help!
    Liz
  36. Neil Bailey
    Liz, i am having LITERALLY the EXACT same issue. I can't access the individual elements of either a query or a structure. If you come up with a solution, please let me know - I have been pulling my hair our for two days over this!

  37. Laura
    Liz and Neil,
    It is not the same if you are returning a structure than a query. If you return a structure, this should work as long as the case is correct:
    oi_price1.text = results.spc_unit_price_mn;
    if you are returning a query, then you receive a recordset in flash, which has its own syntax for accessing the elements. In your example above, you can access it as:
    var record = results.getItemAt(0);
    _root.oi_price1.text = record.spc_unit_price_mn;

    or simply
    _root.oi_price1.text = results.getItemAt(0).spc_unit_price_mn;

    but make sure spc_unit_price_mn has the correct case. It should be like it is in your db (is it all caps?)
  38. Neil Bailey
    I am setting the value of a text field to the results object, just to see what is getting returned; its just a comma seperated list. In the CFC, the return type is a struct, I am setting the CF struct keys the way you specified (to ensure the proper case), but when I try to access results.structKeyName (in ANY fashion - I have tried results.name, results.NAME, results['name'] and results['NAME'] - nothing is working), I get 'undefined'.

    However, when I access results[0] I get the first value. Go figure.......
  39. Liz
    Laura, you are a goddess! results.getItemAt(0) worked! Thank you, thank you, thank you! Where did you find this informaion?
  40. Neil Bailey
    I am setting the value of a text field to the results object, just to see what is getting returned; its just a comma seperated list. In the CFC, the return type is a struct, I am setting the CF struct keys the way you specified (to ensure the proper case), but when I try to access results.structKeyName (in ANY fashion - I have tried results.name, results.NAME, results['name'] and results['NAME'] - nothing is working), I get 'undefined'.

    However, when I access results[0] I get the first value. Go figure.......
  41. Neil Bailey
    My apologies! Case in point: NEVER trust what ANYONE tells you! &quot;Oh, yes the CFC is DEFINITELY returning a query!&quot; or &quot;Oh, yes, the CFC is DEFINITELY returning a struct!&quot; Couldn't POSSIBLY be returning the ARRAY that i found in the returntype of the CFC code! Dumbass......

    Anyway, last question, is there anyway to pass the entire form to a CFC?
  42. Aaron Longnion
    when I click on the Get Date button, I get &quot;Error while calling CFC:Service threw an exception during method invocation: No service named flashRemotingResponder is known to Flash Remoting MX.&quot; Both files in the download are in the web root.

    /flashservices/gateway/ should be correct for my site. I was told if I go to [mySite]/flashservices/gateway/ and I get a blank page, then that confirms that the directory is correct...

    What am I doing wrong?
  43. Jock S
    Is it possible to update Flash Forms with new data with remoting in &quot;real time&quot; or without requiring the user to push some sort of Update button? Thanks.
  44. Neil Bailey
    Jock,

    I would think you would be able to do something with the setInterval function.... have it call a CFC, which returns whatever, every.....however often....

    This is the way I would start. Course, I am fairly far down the totem pole when it comes to experience......
  45. Joe
    Has anyone figured out how to pass form fields back to a cfc by using remoting?
  46. Philippe Maegerman
    I guess it's gonna be
    myService.myMethod(field.text,combo.selectedItem.label,...);
    Then in your CFC, you declare them as arguments:
    &lt;cfargument name=&quot;field1&quot;&gt;
    &lt;cfargument name=&quot;field2&quot;&gt;
    ...
  47. Joe
    Thanks Philippe.

    Anyone have a good example of how to parse through a ColdFusion query recordset in actionscript? I'm getting the query from a cfc call (remoting).
  48. Philippe Maegerman
    Btw, you can find a lot of useful information in the Flash Remoting LiveDocs :
    &lt;a href=&quot;http://livedocs.macromedia.com/flashremoting/mx/Using_Flash_Remoting_MX/asDict.htm&quot; target=&quot;_blank&quot;&gt;http://livedocs.macromedia.com/flashremoting/mx/Using_Flash_Remoting_MX/asDict.htm&lt;/a&gt;
  49. Chip Mayan

    Chip Mayan

    This is exactly what i was looking for! I had heard and read that you couldn't do remoting from a CF7 Flash Form because that is how Macromedia was trying to seperate CF7 from Flex. The only problem I had was trying to send a structure to a cfc. You cannot declare a &quot;new&quot; object as the new keyword is blocked by the server. CF returns an error. So, it isn't like flex. So, if anyone knows how to pass a structure to a cfc then please let me know. Thanks a bunch!
  50. Neil Bailey
    Chip,

    I asked the exact same question above. In the cfc, instead of setting the structure up as structName.keyName = whatever, set it as structName[&quot;keyName&quot;] = whatever. Then in the cfSaveContent variable, access it as result.keyName.

    You need to do it like this to preserve case-sensitivity. As will not see results.keyName if ColdFusion returns it as results.KEYNAME or results.keyname or whatever.

    I had a LOT of trouble getting through this, but make sure your CFC has a return type set to struct, make sure that you set your structure keys correctly in the CFC, and you shouldn't have any problems.
  51. Stephen Moretti
    I'm getting a problem calling my cfc. I can invoke it from a CF page and I can see the cfc in the component browser in dwmx, the CF Component browser and if I call the cfc using the createEmptyMovieClip hack, but if I try to use the cfcexplorer in CFAdmin I get &quot;The component definition file for component 'wms05.orders.OrderForm' cannot be found on this server.&quot; and I get &quot;not found&quot; from the call in cfform.

    wms05 is a CF Mapping to the appropriate folder.
    The &quot;flashservices/gateway&quot; folder exists.

    Here's a snippet of the actionscript :

    //set variables
    var AccountNo = '#session.User.AccountNo#';
    var dsn = &quot;myDSN&quot;;

    //get service
    myService = connection.getService(&quot;wms05.orders.OrderForm&quot;, responseHandler );
    //make call
    myService.getCarriage(dsn,AccountNo,total.text);

    And here is the cfinvoke for the same cfc.
    &lt;cfinvoke component=&quot;wms05.orders.OrderForm&quot; method=&quot;getCarriage&quot; returnvariable=&quot;qryCarriage&quot;&gt;
    &lt;cfinvokeargument name=&quot;DSN&quot; value=&quot;#request.productdsn#&quot;&gt;
    &lt;cfinvokeargument name=&quot;AccountNo&quot; value=&quot;00027&quot;&gt;
    &lt;cfinvokeargument name=&quot;OrderValue&quot; value=&quot;1000&quot;&gt;
    &lt;/cfinvoke&gt;

    I'm at a loss! Any help would be much appreciated.

    Stephen
  52. Stephen Moretti
    Sorry for filling up the comments - I just got a response from Dave Watts on the CF-Talk mailing list that solved my problem and now that I see his description I realise now exactly what a couple of the notes were pertaining to.

    Dave Watts pointed out that although I have a CF mapping to wms05 I probably didn't have a mapping in the webserver to wms05 for the direct call to the cfc by URL (which is what the &quot;connection.getService()&quot; function is actually doing.)

  53. Laura
    Stephen,
    From the notes about remoting in the post:
    &quot;The path to the component is the directory structure as viewed from the root of your website, separated by dots, followed by the component name.&quot;

    That means the path has to be web accessible and also, the directory structure has to exist, either by real directories or by web server virtual directories. You must be able to browse to that folder and cfc. CF mappings are not enough, as the web server has no idea of their existence.
  54. Tim
    Great article. I am almost there--Im just missing the middle piece that connects it all.

    In one CFFORM, I have a CFGRID that contains rows from a query. Then I have three textarea elements. When you click on a row in the grid, I want the textarea elements populated from the result of a method call to my CFC.

    I think I understand the &quot;getData&quot; code, but how do I trigger the remote call when I click on a row in my cfgrid? The method I am calling expects an ID (which is one of my columns in the cfgrid).
  55. Tim,
    Cfform has an event on the grid that is called &quot;onchange&quot;. This gets executed everytime the user selects a row. You need to make the call to your cfc inside that event.
  56. I was playing around with this a bit and found out that you can even debug the data transfer using the NetConnection Debugger (which comes with Flash Remoting if you have it installed).

    Just add the following line at the top of the cfsavecontent block:

    // enable NetDebugger
    mx.remoting.debug.NetDebug.initialize();


    Open the NetConnection Debugger before opening the .cfm page and watch the data displayed in the Debugger ;-)

    regards,
    Muzak
  57. I am trying to pass a cfselect box over that has more then 1 value selected. Well when I pass it over only 1 value gets passed. I thought for sure it was because the comma so I did a replace right before I pass it and I still only get 1 value.

    var responseHandler = {};

    var Type = Type.value.split(&quot;,&quot;).join(&quot;|&quot;);

    responseHandler.onResult = function( results: Object ):Void {
    //when results are back, populate the cfgrid
    searchResults.dataProvider = results;
    }

    responseHandler.onStatus = function( stat: Object ):Void {
    //if there is any error, show an alert
    alert(&quot;Error while calling cfc:&quot; + stat.description);
    }

    //get service
    myService = connection.getService(&quot;ssLite&quot;, responseHandler );
    //make call
    myService.getSerchResults(Type);


    &lt;cfselect enabled=&quot;Yes&quot; name=&quot;Type&quot; size=&quot;3&quot; label=&quot; Type:&quot; multiple=&quot;yes&quot;&gt;
    &lt;option value=&quot;0&quot; SELECTED&gt;All Types&lt;/option&gt;
    &lt;option value=&quot;typea&quot;&gt;A&lt;/option&gt;
    &lt;option value=&quot;typeb&quot;&gt;B&lt;/option&gt;
    &lt;option value=&quot;typec&quot;&gt;C&lt;/option&gt;
    &lt;option value=&quot;typed&quot;&gt;D&lt;/option&gt;
    &lt;/cfselect&gt;
  58. Nolan Dubeau
    Hello,

    I am having some serious problems deploying my app to a live server and wonder if you could explain about the façade component with regards to Remoting. It appears that there are some comments on this issue, but I am at a loss to resolve. On my local machine the path to my components is www_mysite_com.com.concrete.somecomponent.cfc, and on the live server I created a CF mapping called www_mysite_com, and pointed it to the root directory of the site. Everything seems to be working correctly except for the Remoting calls. Any help is appreciated.
  59. Nolan, you may want to ensure that your jrun and coldfusion are not clashing against the flashservices/gateway - see
    http://www.talkingtree.com/blog/index.cfm?mode=entry&amp;entry=25AA89CA-45A6-2844-79F890861E204161

    One issue I am having is applying a filter after calling the onClick=&quot;#getData#;applySomeOtherFilter()&quot;. The getData gets called, but the applySomeOtherFilter doesn't work. Without the #getData# call the filter does work. Any suggestions?
  60. Laura
    Nolan,
    Flash remoting ignores CF mappings. The path has to be exactly your path from the root to the cfc, as if you were browsing it, just replace the slashes with dots. (Check the notes on remoting in the post) As a side note, you can have a virtual directory in IIS and that would be fine, because you can browse it, but not CF mappings.

    Matt,
    I think your problem is that you are calling the filter before the data gets back. You need to have your filter in the onResult or myFunction_Result function. These are asynchronous calls, so the data is not available as soon as you make the function, and there is no guarantee about when it will arrive.
  61. Thanks Laura. I moved the filter into the onResult function. What happens is that after the following line:
    clientGrid.dataProvider = results; // where results have 7 records

    clientGrid.dataProvider.length is equal to 7
    However, I am not able to iterate over the newly populated data grid for some reason. ie clientGrid.dataProvider[1][&quot;columnname&quot;] is empty.
    Any suggestions?
  62. Laura
    Matt,
    For your example to work, you need to set the dataProvider as:
    clientGrid.dataProvider = results.items;
  63. Mike
    Laura,

    I want to return just one row of a query from a cfc. But I can't figure out the correct way to get it from the cfc back to the cfm. It always comes up as undefined. If I go from returntype=&quot;string&quot; I get a different error. Any help would be appreciated.

    Mike
  64. Laura
    Mike,
    If you are sending the query directly, then access the first (and only) item by:
    var item:Object = results.getItemAt(0);
    then item is a structure with columns as keys.
    item.myColumn
  65. colin
    Hi there,

    I am trying to display the data returned from a cfdirectory query, for some reason i get the headers back, but not the actual data list.
    any reason that you may know of ? Everything works fine if i use an actual db query name.

    Thanks in advance :)

    NetConnectDebugInfo:
    --------------------------
    Result (object #2)
    .....mRecordsAvailable: 0
    .....serverInfo: (undefined)
    .....uniqueID: 0
    ....._items (object #3)
    ..........No properties
    .....mTitles (object #4)
    ..........[0]: &quot;Name&quot;
    ..........[1]: &quot;Size&quot;
    ..........[2]: &quot;Type&quot;
    ..........[3]: &quot;DateLastModified&quot;
    ..........[4]: &quot;Attributes&quot;
    ..........[5]: &quot;Mode&quot;
    ..........[6]: &quot;Directory&quot;

  66. Ken
    I have the following situation.
    I need to check if a value entered into a text box already exists in the db.

    No problem there I have modified your great example of flash remoting to do this.
    But if the value is found, I would like to display to the user an alert message (plus disable the submit button, which I have done)

    But I have also used your alert example and the problem I encounter is that it just hangs until a message come back saying that the script is causing the player to run slowly.

    Can you shed some light on this problem ?
    I should also say that if I don't use your alert example and just use
    alert('my alert text');
    it works, but as the form is long the alert message is not displayed on the screen, the user has to scroll down to it. I have also not been able to &quot;move&quot; this alert.
  67. Ken
    An update of my lost post

    I have found that the problem with this is the scope setting of &quot;this&quot;, if I change this to &quot;_root&quot; it all works as expected. But of cause the alert box will not close. I have tried replicating the deletePopup() code from flash but no luck as yet.

    Ken
  68. Ken
    I have tried this, _root, _level0

    But it's most probably where I have to put it is the problem.
    Here is my code

    responseHandler.onResult = function( results: Object ):Void {
    //when results are back, we show the text received
    display.text = results;

    var alertSettings:Object = {closeButton:true, title:'Warning', message: &quot;My Message&quot;, width:350, x: 60, y: 10, headerHeight: 27};

    var myTW = mx.managers.PopUpManager.createPopUp(_root, FormErrorException, true, alertSettings);

    var windowListener = {};
    windowListener.click = function(){
    _root.myTW.deletePopUp();
    }
    myTW.addEventListener(&quot;click&quot;, windowListener);}

    I have tried a number of combinations all with no result.
  69. Ken
    As I said, just putting the _root in the wrong place.

    Heres the code that works

    var msg = 'A simple alert with position x:60, y:10';
    var alertSettings:Object = {title:'Off center', message: msg, headerHeight:27, x: 60, y: 10};
    _root.errorpopup = mx.managers.PopUpManager.createPopUp(_root, FormErrorException, true, alertSettings);

    Ken
  70. Laura
    Ken,
    I am glad you got it working.
    However, as I said the post http://www.asfusion.com/blog/entry/customizing-a-cfform-alert-with-pictures-and
    I would strongly recommend *against* using the errorpopup variable. It depends too much on current cfform implementation code. If you use it, you must be willing to accept that your code may break in future CF releases.
  71. Ken
    Laura,
    Thanks for the response. Yes, I did read your comments in your example and yes I do agree.
    But as the form I have is long (I have no option here, clients !!), I have to resolve the alerts being displayed in a position that you have to scroll down to them. If I could find a way to move the normal &quot;alert&quot; then I would use them.

    Just have to be aware that the code may break.

    Ken
  72. I get this error when I click Get Date:

    &quot;Error while calling cfc: Service threw an exception during method invocation:null&quot;

    Is there something wrong with my Flash Remoting configuration? I am using ColdFusion MX 7.0.1 (merged with Flex). Both files are in my root folder and the server name is cfusion.local (for development use). So I set the connection and get service values as follows:

    var connection:mx.remoting.Connection = mx.remoting.NetServices.createGatewayConnection(&quot;http://cfusion.local/flashservices/gateway/&quot;);

    myService = connection.getService(&quot;flashRemotingResponder&quot;, responseHandler );

    Can anyone tell me what the source of the error is?
  73. Laura,

    Thank you for explaining remoting! This has helped me to understand the requirements for returning results. Thanks!

    -Richard
  74. MJE
    Hi,

    I am hoping that this example can solve my woes. I'm losing it over here! Here is the issue - I need to be able to filter an item in a select list based on an item that is selected in a datagrid (which in turn binds three of the grid fields to text boxes).

    In my mind, the easiest way to do this would be to have a query that basically says select * from table where value=&quot;{mydata.text}&quot; - of course, that would be in a perfect world, and I have not, for the life of me, been able to figure out how to query using cf.query or cfscript, or this example, so that I can filter the select box based on either the item selected in the data grid, or the text box that it is bound to.

    Here is what I am working with so far - the job guide section below is what needs to be made dynamic based on the publication chosen:

    &lt;cfgrid name=&quot;grid&quot; query=&quot;getPublications&quot; selectmode=&quot;single&quot; rowHeaders=&quot;false&quot; height=&quot;100&quot; tooltip=&quot;Choose a source reference from the list below&quot;&gt;
          &lt;cfgridcolumn name=&quot;publication&quot; width=&quot;300&quot; header=&quot;Source Reference&quot; &gt;
          &lt;cfgridcolumn name=&quot;pubDate&quot; header=&quot;Pub Date&quot; display=&quot;false&quot; mask=&quot;MM/DD/YY&quot;&gt;
          &lt;cfgridcolumn name=&quot;changeTitle&quot; width=&quot;75&quot; header=&quot;Change Title&quot; display=&quot;false&quot; &gt;
          &lt;cfgridcolumn name=&quot;changeDate&quot; header=&quot;Change Date&quot; display=&quot;false&quot; mask=&quot;MM/DD/YY&quot;&gt;
       &lt;/cfgrid&gt;
    &lt;/cfformgroup&gt;   
           &lt;cfformgroup type=&quot;Horizontal&quot; label=&quot;Publication:&quot;&gt;
               &lt;cfinput tooltip=&quot;Choose a publication/source reference from the list above&quot; type=&quot;text&quot; name=&quot;taskPublication&quot; bind=&quot;{grid.selectedItem.publication}&quot;
        required=&quot;no&quot; message=&quot;Please select a task publication&quot; editable=&quot;false&quot;&gt;
           &lt;/cfformgroup&gt;
           &lt;!--- pub date, change title and change date ---&gt;
    &lt;cfformgroup type=&quot;HBox&quot;&gt;
    &lt;cfformgroup type=&quot;VBox&quot;&gt;
    &lt;cfinput type=&quot;text&quot; name=&quot;pubDate&quot; label=&quot;Pub Date:&quot; bind=&quot;{grid.selectedItem.pubDate}&quot; editable=&quot;false&quot;&gt;
    &lt;/cfformgroup&gt;
                   &lt;cfformgroup type=&quot;VBox&quot;&gt;
    &lt;cfinput type=&quot;text&quot; name=&quot;changeTitle&quot; label=&quot;Change Title:&quot;bind=&quot;{grid.selectedItem.changeTitle}&quot; editable=&quot;false&quot;&gt;
    &lt;/cfformgroup&gt;
    &lt;cfformgroup type=&quot;VBox&quot;&gt;
    &lt;cfinput type=&quot;text&quot; name=&quot;changeDate&quot; label=&quot;Change Date:&quot;bind=&quot;{grid.selectedItem.changeDate}&quot; editable=&quot;false&quot;&gt;
    &lt;/cfformgroup&gt;
    &lt;/cfformgroup&gt;
                
          &lt;!--- job guide - THIS IS THE AREA that needs to be filtered by publication selected - all I need to be able to do is figure out how to get the taskPublication field, or the publication field selected in the grid to be used as a variable to filter the job guide - Please help! ---&gt;
    &lt;cfformgroup type=&quot;HBox&quot;&gt;
    &lt;cfformgroup type=&quot;VBox&quot;&gt;
    &lt;cfselect name=&quot;jobGuide&quot; label=&quot;Job Guide No:&quot;&gt;
          &lt;option value=&quot;&quot;&gt;Select a job guide&lt;/option&gt;
    &lt;cfoutput query=&quot;getJobGuides&quot;&gt;
    &lt;option value=&quot;#jobGuide#&quot;&gt;#jobGuide#&lt;/option&gt;
    &lt;/cfoutput&gt;
    &lt;/cfselect&gt;
              &lt;/cfformgroup&gt;
  75. MJE
    OK, I got the select able to populate using the flash remoting for cfselect example - thanks!!

    Now, I'm getting the same issues with the binding mentioned earlier, but the posted resolve did not work for me. All I did was copy and paste the code that worked into my test page with the cfselect. This is the final missing piece - is there another 'foolproof' binding format that I can use?
  76. MJE
    Sorry again to take up the space - stupid me - in my haste I did a select * from table and the first letter by default was a capital letter, which I wasn't specifying. All is well - thanks so much for posting all of this information to the site - this is one of my most invaluable resources while developing with flash forms!
  77. Don
    I still dont get it, it works in the root directory but no wher else, I dont understand where to edit the path.CFC. I dont understand your examples if none of the text matches up where I can find it in the source
  78. Ed
    I must say this is the kewlest thing! I was trying to do the same thing with all kinds of hacks and found this post. This solution is awesome! It does exactly what I needed to do. Any thoughts on performance impacts? Like what will remoting act like if there are hundreds/thousands of users?
    Laura, you are the MA... er,well you ROCK! Thanks so much for the post!
  79. David
    Are the /flashservices/gateway directories actual physical directories? Or is that just a placeholder value in the opening of the &lt;cfsavecontent&gt; tag? The directories are nowhere to be found on my machine--which is running CFMX 7.

    Was there an option to install the flash service during CF installation that I could have deselected?
  80. Laura
    David,
    /flashservices/gateway are not actual directories. They are a servlet mapping defined in the web.xml file and it is installed by default. In previous versions, you could see a blank screen if you browsed directly, but that is not the case anymore, the simplest way to make sure you have it properly installed is to run the code and see if it works :)
  81. daniel fredereicks
    Ok, so i read that flash remoting takes the place of outside swf files...
    What if I am trying to insert a swf file into say an accordion? I can get it to display using the &lt;img&gt; tag, but, i am also using flash remoting, which for some reason does not seem to bring bacm my data and display.
    Is there any conflict between cf flash forms and the swf?

    I really need to find this answer.

    dan
  82. Tom
    I get a error message...EVERY time I try to run a search.


    &quot;Element USERNAME is undefined in VARIABLES&quot;
  83. Daniel Fredericks

    Daniel Fredericks

    NetConnection Debugger...how do you open it to view your CF pages? isn't the debugger within flash?

    Help me on this....
  84. Gerald
    Nice. How would one submit and process the contents of a grid (multiple rows possibly) via flash remoting? If the answer is not simple, direction to any resources will be appreciated. Thanks much!
  85. Brian
    I donwloaded the two source available above and tried them out on my server but I'm wondering why I'm getting this error: "error while calling cfc: service, flashRomotingResponder not found" I'm obviously new to flash remoting but very excited about it.

    Checklist:
    -Coldfusion mx 7
    -I see the flash form and form elements
    -Click on "Get Data"
    -Then error is called with flash pop-up.

    Thanks, Brian
  86. Laura
    daniel,
    It is very difficult to say what exactly your problem with the swf is. It should work fine, but remember there will be no communication between the form and your swf unless you program it to do so.

    Tom,
    That means you have an error in your cfc.

    Gerald,
    You could loop over the records of your datagrid and create an array with the data you need or if you loaded the grid normally (not manually via remoting), you could send the dataprovider directly and receive it as an array in CF.

    Brian,
    The example assumes you have your file in the root of your site (http://www.example.com/simple-remoting.cfm ) If that is not your path, then you need to change it in the line that calls the service (getService())
  87. Rey
    I'm trying to use flash remoting to insert data into a database but it's not working, here is my savecontent tag:
    <cfsavecontent variable="checkValues">
          if (emp_NAMEa.text == '')
          {
          mx.controls.Alert.show('Employee Name is required!');
          }
          else if (FTa.text == '')
          {
          mx.controls.Alert.show('Employee Status is required!');
          }
          else if (TITLEa.text == '')
          {
          mx.controls.Alert.show('Employee Title is required!');
          }
          else if (DM_NAMEa.text == '')
          {
          mx.controls.Alert.show('District Manager Name is required!');
          }
        else if (DOHa.text == '')
          {
          mx.controls.Alert.show('Date of Hire is required!');
          }
          else if (SVC_MGR_NAMEa.text == '')
          {
          mx.controls.Alert.show('Service Manager Name is required!');
          }
          else
          {
          //create connection, replacing the gateway url with yours
    var connection:mx.remoting.Connection = mx.remoting.NetServices.createGatewayConnection("http://localhost/flashservices/gateway/");
       
    //declare service
    var myService:mx.remoting.NetServiceProxy;
    //put the controls in scope to avoid calling _root
        var emp_NAMEa = emp_NAMEa.text;
        var FTa = FTa.text;
        var TITLEa = TITLEa.text;
        var DM_NAMEa = DM_NAMEa.text;
        var DOHa = DOHa.text;
        var SVC_MGR_NAMEa = SVC_MGR_NAMEa.text;
       
        //make an object that will handle the response
    var responseHandler = {};
       
        //function that receives the response
    responseHandler.onResult = function( results: Object ):Void {
    //when results are back, we show the text received
    var msg = results;
    }
        //function that receives any error that may have occurred during the call
    responseHandler.onStatus = function( stat: Object ):Void {
    //if there is any error, show an alert
    alert("Error while calling cfc:" + stat.description);
    }
        myService = connection.getService("cfc.add_emp", responseHandler );
    //make call, passing one parameter
    myService.addEmp(emp_NAMEa.text,FTa.text,TITLEa.text,DM_NAMEa.text,DOHa.text,SVC_MGR_NAMEa.text);
          }
       </cfsavecontent>
    and here is my cfc:
    <cfcomponent>
       <cffunction name="addEmp" access="remote" returntype="string">
        <cfargument name="TITLEa" type="string" required="false" default="">
        <cfargument name="emp_NAMEa" type="string" required="false" default="">
        <cfargument name="FTa" type="string" required="false" default="">
        <cfargument name="DOHa" type="string" required="false" default="">
        <cfargument name="DM_Namea" type="string" required="false" default="">
        <cfargument name="SVC_MGR_NAMEa" type="string" required="false" default="">
           <!---Add employee--->
    <cfswitch expression="#form.TITLEa#">
    <cfcase value="Bio Sys Service Supervisor">
    <cfset TechCode = "Sup">
    </cfcase>
    <cfcase value="Bio Sys Service Manager">
    <cfset TechCode = "Man">
    </cfcase>
    <cfcase value="Bio Sys Service Specialist">
    <cfset TechCode = "Tech">
    </cfcase>
    <cfcase value="Bio Sys District Manager">
    <cfset TechCode = "DM">
    </cfcase>
    </cfswitch>
    <cfquery datasource="stcycle">
    INSERT INTO dbo.payroll (TechCode, emp_NAME, FT, DOH, TITLE, DM_Name, SVC_MGR_NAME) VALUES ('#form.emp_Namea#','#form.FTa#','#form.DOHa#','#form.TITLEa#','#form.DM_Namea#','#form.SVC_MGR_NAMEa#','#TechCode#')
    </cfquery>
    <cfset msg = 3>
          <cfreturn msg>
       </cffunction>
    </cfcomponent>
    Any thoughs as to why it's not working correctly, meaning it's not inserting the values passed by the form into the database, I have been at this for 2 days now, Please Help!!!
  88. Ed
    Hi Rey,
    Providing you are not getting an error...
    Try removing the form. in front of your cold fusion variables in the insert statement... Remoting does not use the form scope. For example try this:

    INSERT INTO dbo.payroll (TechCode, emp_NAME, FT, DOH, TITLE, DM_Name, SVC_MGR_NAME) VALUES ('#emp_Namea#','#FTa#','#DOHa#','#TITLEa#','#DM_Namea#','#SVC_MGR_NAMEa#','#TechCode#')

    Also, remove the .text in the call below...
    myService.addEmp(emp_NAMEa.text,FTa.text,TITLEa.text,DM_NAMEa.text,DOHa.text,SVC_MGR_NAMEa.text)

    You are referencing the variable that already holds the text in the variable calls above...

    Also..
    In your insert call your variables appear to be out of order. Try putting '#TechCode#' in the beginning of the values call to match the column name list.

    If you are getting a remoting error... Let me know.
    Hope this helps!

    Ed
  89. Rey
    nope nothing works, for some reason I don't even get errors even after applying the changes you recomended, I click the button and nothing happens. I really don't understand why would they make it so difficult to do this, also too much code for a simple DB insert.
  90. Rey
    nope nothing works, for some reason I don't even get errors even after applying the changes you recomended, I click the button and nothing happens. I really don't understand why would they make it so difficult to do this, also too much code for a simple DB insert.
  91. Ed
    Hi Rey,
    A couple of other things i see here that may help...
    In the myService.addEmp it appears that your variables you are passing are out of order with the component...
    The variables you pass must be in the same order as the arguments listed in the component... So I would change the call to this...
    myService.addEmp(TITLEa, emp_NAMEa, FTa, DOHa, DM_NAMEa, SVC_MGR_NAMEa);
    Again make sure your query is correct...
    <cfquery datasource="stcycle">
    INSERT INTO dbo.payroll
    (
    TechCode, emp_NAME, FT, DOH, TITLE, DM_Name, SVC_MGR_NAME
    )
    VALUES
    (
    '#TechCode#', '#emp_Namea#','#FTa#','#DOHa#','#TITLEa#','#DM_Namea#','#SVC_MGR_NAMEa#'
    )
    </cfquery>

    In your result handler responseHandler.onResult you are just setting a variable var msg = results;. If you want to see the results coming back from the remoting call perhaps you should use alert( String(results)); Also, is you are returning a string bypt from the component then you should thange the results:Object type to results:String.
    In my components I use the following component tags
    <cfcomponent name="item_info" access="public" description="">
    I don't think that makes a difference but thought I would pass it along.
    Make sure that your component is physically located within the web root of the web server. In this case it looks like you are using localhost so that would mean you are using your machine to develop on..? So therefore your, based on your connection.getService call you cfc's should be located <C>:/<webroot>/cfc/. Basically in the cfc directory off the webroot for your web server.
    The power of remoting is the fact that you can update the database from flash forms without refreshing the page and it really makes your application significantly quicker and appear more like an application than a web page. I use it a lot and really like the way it makes the applications cleaner and quicker.
    Hang in there... Once you get it you will dig it!
    Hope this helps,
    Ed
  92. Rey
    Thanks Ed for all your help, one thing that you said about the location of the CFC I created a directory on the root of the actual website called CFC so meaning that the path would look like this http://www.stericycleweb/cfc/add_emp.cfc so how I'm I suppose to enter the path? I though it would be like this(cfc.add_emp)
  93. Ed
    Hi Rey,
    That is correct however in your call..
    createGatewayConnection("http://localhost/flashservices/gateway/";);
    you have localhost which should be
    createGatewayConnection("http://www.stericycleweb.com/flashservices/gateway/";);
    or actually even better:
    createGatewayConnection("http://#cgi.HTTP_HOST#/flashservices/gateway/");
    then the cf server will put in the host of the server. Make sure to wrap it in a cfoutput..:>
    Hope this helps.
    Ed
    Any more questions email me at [email protected]...
  94. Tom
    It was easy for me to get all results from CF to Flash, knew about Flash case sensitivity and got it on first pass. Sending strings / numbers to Flash works find. But I get strange error when trying to send a structure (Object) to CF. No one in 100 posts mentioned this, but I am sure people are sending stuff back to CF. The error is bizzare since Flash claims that it sent a structure - in its call using NCD while CF complains that it didn't get it - I checked and CF doesn't receive the data. Hope there is a workaround for this, as far as I can tell I am doind everything correct and I am comfirmed in this by NCD. Is this yet another Flash bug? Workarounds?
  95. Laura
    Tom,
    See this post: http://www.asfusion.com/blog/entry/how-to-transfer-data-with-flash-remoting in the section: Structures and objects. I wrote another workaround in this comment too: http://www.asfusion.com/blog/entry/how-to-transfer-data-with-flash-remoting#comment-426

    Basically, the idea is that if you send a sole structure, each key gets converted to an argument, so you are actually receiving as many arguments as your original object had. This would be similar to myFunction(argumentCollection=myStructure)
  96. Court
    I am having the same problem as Brian on this post with gettting a "Event Handler Exception" error. I've tried the suggested solution after his post and either I don't understand the solution or it doesn't work for me.

    Basically, in the root of the admin website... I have an application.cfc (C:\inetpub\wwwroot\admin\application.cfc).

    On one of my pages I have a CFFORM using CFGRID and Flash Remoting to populate the grid. The cfform calles a cfc located at admin._model.cfc.cfformRemote (C:\inetpub\wwwroot\admin\_model\cfc\cfformRemote.cfc)

    When it makes the call, it get the error. If I put the cfformRemote.cfc in the root of the website (
    C:\inetpub\wwwroot\) I dont get any errors and the call to the cfc is successfull.

    Help?!? Please :(
  97. Laura
    Court,
    From what you show, the path seems to be ok as long as you use it in connection.getService(). What does the error say exactly? Could there be anything in the cfc that fails when it is moved?
  98. Court
    Oh got it figured... it was that stupid application.cfc and not allowing other cfcs to work unless u do a "applicationproxy.cfc" trick.
  99. Court
    I'm now trying to figure out how to upload to a server via Flex 2 and CF.
  100. Sowmya Nayak

    Sowmya Nayak

    I have tried a lot to get this simple application running on my multihomed development server but in vain. I have placed the CFC under the webroot, the path being com.asfusion.flashRemotingResponder

    The index.cfm file is under another website on the same machine. It does have CFIDE as a virtual directory. When I try to run the example, it gives me an error: Service com.asfusion.flashRemotingResponder not found.

    But when I run the example under the web root, it works perfect without any problems. Any ideas to this problem?

    Thanks.
  101. Laura
    Sowmya,
    See the second paragraph on "A couple of notes on Remoting" in the post. If you use something like: com.asfusion, then your folders from the webroot must match that (com/asfusion/) and have the component there.
  102. Sowmya Nayak

    Sowmya Nayak

    Thanks for your quick response, Laura. I do have the component in the wwwroot/com/asfusion/ folder. I can see the introspection page in the component browser too and I can access the component from other coldfusion pages as well.
  103. Laura
    Sowmya,
    What do you mean by "the index.cfm file is under another website on the same machine"?
  104. michael white
    I wonder if my problems relate to Sowmya's. I have an IIS 6 server called gandalf so I can refer to it as http://gandalf/ but I almost never do. All of my projects are separate websites on the gandalf server with host header access so when I call my project it would be something like http://affinity.cove.com which is an entirely private DNS name that points to gandalf. when gandalf sees that url it sends the request to a particular directory and treats it as the root of the site even though it's really a subdirectory (C:\inetpub\wwwroot\affinity) so the question is: how does that affect flash remoting? do I need additional configuration? how do i refer to the cfc and remoting service?
  105. Jason
    How do I use remoting to send the data from a grid and insert it into a database?
  106. Jason
    To add more detail to my previous post, I'd like an example of how I pass grid data to a cfc and then how to handle it appropriately in the cfc.
  107. Maggie

    Maggie

    Just wanted to say that you guys are THE BEST - this site helps me out more than words can say...
  108. Mark
    I'm having some trouble generating the values in the grid, once I click on the search results. None of the values appear, accept for the search values. There seems to be nothing wrong with my binding.

    bind="{(data.selectedItem!=undefined)?data.selectedItem.location:''}"

    I'm running this on localhost and using Access and Unicode. Could this be a problem??

    Please, if anyone can help I would be very grateful.
  109. Robert C

    Robert C

    Can't thank you enough for providing this information.

    I had been banging my head against a wall trying to update a grid this way using a database query and was just utterly stumped.

    When implementing this method first ran into the "Event Handler Exception" problem and then read and re-read all the comments and finally realized I was using onRequest in my Application.cfc for logging people off the site. So had to recode the site a little to fix that issue.

    One I figured out it was onRequest everything just worked the way it was supposed to.
  110. kll57
    I'm new to flash remoting and this site has been a great help in getting started. I have the flash remoting, filtering as you type and the bindings working. I'm now struggling trying to populate a 2nd grid based on the key in the first grid. The first grid populates and when a user selects a record it populates the panel on the right side for editing. Inserts, updates and deletes are working with this. Now I need to populate a grid on this panel with information from a child table. The query for the child table is in the same component as the master query.

    In the onchange for the master grid I'm trying to call the function that will get the datat from the component. I need to pass the key from the master grid to the function that makes the function call to the function in the component so the query will only pull the records associated with the key. I've read through most of the posts and still can't seem to figure this out.

    The master grid is called userGrid and the child grid is userIdGrid.

    The onChange event calls the following function:

    getUserid(userGrid.selectedItem.SSN)

    The getUserid function makes the call to the component: This is were I get really confused and know I'm not doing it right. I've tried various ways of doing this. This is what I currently have:

    public function getUserid(grid:mx.controls.DataGrid):void
    {
    var userArgs:Objec t= {};
    <cfoutput>
    userArgs.ssn = userGrid.selectedItem.ssn;
    </cfoutput>
    _global.listingService.queryUserid(userArgs);
    setMode('add');
    mx.managers.CursorManager.removeBusyCursor();
    }

    listingService is the name of the service that I connect to - which is working for the master grid and all inserts, updates and deletes.

    querUserid is the name of the function that makes the query to the child table and is in the same listingService.

    I've set up another response Handler for this and it looks like this:

    var userIdGrid:mx.controls.DataGrid = userIdGrid

    responseHandler.useridResult = function( results:Object);Void
    {userIdGrid.dataProvider = results.items;
    setMode('add');
    mx.managers.CursorManager.removeBusyCursor();
    }

    when I run the page and click on the master record I get the message The parameter SSN to funciton queryUserid is required but was not passed in.

    This is all new to me so I'm sure I have plenty wrong with the code.

    I would appreciate any help, this has been driving me crazy for days.

    Thanks in advance for any help.

    Kim
  111. Ed
    Hi Kim,
    This may be scoping issue. When you call userGrid.selectedItem.ssn try using _root.userGrid.selectedItem.ssn. Depending on where your function is located sometimes flash forms looses scope. The one thing to consider here is that _root is kinda a hack and may not be compatible in future releases. You could scope the grid in a more global way. I believe Laura has addressed this in the original text of this post.
    Hope this helps,
    Ed
  112. kll57
    Hi Ed,
    Thanks for the response. I did scope the grid in a global var - _global
    but I didn't pass it that way to the function, I'll gave it a try and I
    still got the same error. I think the way I passing it is not right or the
    way I'm receiving it in my function is wrong. If you think of anything else
    I'll give it a try.

    Thanks,
    Kim
  113. kll57
    Follow-up to my post on 6/12/07. I finally got the second grid to populate when I selected a record from the first grid, unfortunately I lost the text input fields for the master record that I was binding to from the Master grid. now I'm just getting the detail records.
    The two grids are populated by 2 different queries that reside in the same CFC.

    I first populate the Master grid (userGrid) then when a row is selected I pass the selected rows primary key to the function that calls the detail query in the cfc. This query selects only the records where the Master primary key = the foreign key in the detail table.

    This is a sample of the code that is in the script tag that deals with the grid:

    var responseHandler:Object = {};

    var userGrid:mx.controls.DataGrid = userGrid; (this is the master grid)
    var userIdGrid:mx.controls.DataGrid = userIdGrid; (this is the detail grid)

    responseHandler.onResult = function ( results: Object):Void
    {userGrid.dataProvider = results.item;
    _root.setMode('add');
    mx.managers.CursorManager.removeBusyCursor();
    }

    responseHandler.queryUserid_Result = function (results: Object):Void
    {userIdGrid.dataProvider = results.item;
    _root.setMode('add');
    mx.managers.CursorManager.removeBusyCursor();
    }

    On form load calls the getData() that populates the Mastergrid using the master query in the CFC - this works.
    the getData() looks like this:

    public function getData():Void
    {
    var qArgs:Object {};
    <cfoutput>
    qArgs.status = '#session.status#';
    </cfoutput>
    _global.listingService.queryAll(qArgs);
    _root.setMode('add');
    mx.managers.CursorManager.removeBusyCursor();
    }


    The master grid makes the call to populate the second grid (getUserid() in the onchange event, the PKNO column is the primary key:
    <cfgrid name="userGrid" ........ onchange="userGridChanged();getUserid(userGrid.selectedItem.PKNO)">

    The getUserid () looks like this:

    public function getUserid(pkno:String):Void
    {
    var userArgs:Object {};
    <cfoutput>
    userArgs.pkno = pkno;
    </cfoutput>
    _global.listingService.queryUserid(userArgs);
    _root.setMode('add');
    mx.managers.CursorManager.removeBusyCursor();
    }

    This function is populating the detail grid with the correct data. When I select a row from the master userGrid.

    The right hand panel has textinput fields for the master record that are bound to the master grid- userGrid. Below these textinput fields I have the detail grid - userIdGrid that can contain 1 or more rows. I can only get one or the other to populate, not both.

    Is there a problem with the resultHandlers each specifing the .dataprovider?

    Any help would be greatly appreciated.

    Thanks in advanced for any help,
    Kim
  114. Pp
    How to cheack valiable type of retuen results
  115. Db
    Trying out the RE app. I've added two checkbox fields to the database....updated the flash form and SubmitSearch function on the index.cfm. Also, updated the ListingService cfc. The check boxs get brought in to the application but I cannot search on them. Is there something I'm missing? Please help.
  116. Ambika Dayal
    This tutorial is great!
    I tried the tutorial to load data in the grid from an Access database and it worked great! However, when I try it loading it from an Oracle database - the grid appears as though it is loaded, but I am unable to see the data. I can tell that the grid seems loaded, because the scroll bar size changes.

    All examples I have seen on the web are with Access databases. Is there a problem with Oracle? Has anyone had the same experience?
    I would appreciate any help, suggestions, comments.

    Thanks a lot
  117. Ambika Dayal
    I figured out my problem. One of your comments above helped me figure it out. In Oracle, the fields are in caps and after I changed the fieldnames to caps, its working!

    Thanks anyway and keep up the great work!
  118. chaita
    Hi all,

    I am new to ColdFusion flash remoting. I downloaded the files and copied in my sys. it’s not showing the date. When I am pressing GET DATE button its simply sitting there.
    My system structure is ColdFusion software is in 'c' folder and the default web sites are in’d’ folder.
    I had a doubt its really looking for cfc file are not I don't know. I remove the CFC file from that path even though it’s not throwing the error at all.
    Appreciated for early response
  119. Tim
    I'm using this example and it works very well. CFC is returning the data to the grid, however, the grid is editable. On form submit, I get all empty arrays where I would expect to have results from edited cells.

    Any ideas?