Our Blog

We've had very good feedback from the first part of the ColdFusion Flash Forms article published at Macromedia. Thank you!

Many of you have asked when the second part is going to be published. The answer is: soon! But some readers have asked Macromedia and us to be able to see it sooner. So we decided to post it here for download until it is finally published at the Macromedia Developer Center.

Enjoy!

Update: The article has been published by Adobe, so these are the new links

The Real Estate Sample Application - Part 2: Managing Property Listings through Flash Forms
Sample files
Live example

Related posts: ColdFusion Flash Forms Macromedia Developer Center article - Part 1

Laura

Laura

142 Comments

  1. Was just checking out the dev site the other day to see if part 2 was up...this is by far the best remoting tutorial Macromedia have on their site...even better than the flash ones.

    Really good stuff keep it up :)
  2. Josh Rodgers

    Josh Rodgers

    Hello, great to see Part 2 out. Unfortunately I am getting an error.

    I had Part 1 installed, and it was working fine.

    I recoppied the new files over the old ones and tried to hit the index.cfm page.

    Heres what i got:

    Element STATESGATEWAY is undefined in a Java object of type class [Ljava.lang.String; referenced as

    The error occurred in C:\JRun4\servers\cfflex\cfusion.ear\cfusion.war\realestate\index.cfm: line 6

    4 :    
    5 :    //get all states
    6 :    getstate = request.statesGateway.getAll();
    7 :    
    8 :    //make a query of prices
  3. Josh Rodgers

    Josh Rodgers

    Ok ignore my previous post it works fine. I somehow forgot to copy over the new application.cfc file :(

    FIxed looks fantastic!

    Thanks for your hard work.

  4. Vince
    Thanks for the great articles!

    In the real estate example, if no results are returned when you search for a property, how could you capture that and either : call another function or event?

    I'd like to do something similar to your search functionality, but if nothing is returned in 'result', I want to create an alert that says " no records found, etc...". I haven't had any luck so far.

    Thanks for any help!
  5. Xerrano
    GREAT LOOKING...

    I just install this new version, but Im getting an error message when trying to search or adding a new property.

    This is the error message:
    ___________________________________________
    Error: Service
    realestate.services.ListingService not found.
    ___________________________________________

    I can see the file "ListingService.cfc" in the services directory...


    ANY IDEAS... THANKS!
  6. Zach Stepek

    Zach Stepek

    Xerrano,

    Just a shot in the dark, but are you sure that remoting is enabled on the server? I was receiving similar errors with another app, and that was the issue, my host hadn't enabled the flash remoting gateway on my CF server.

    Hope this Helps
  7. Xerrano
    Thanks Zach

    You may be right, that could be the issue to my problem
    Last week I upgrade my coldfusion 6.5 to 7.0.1 (mac os x).
    Practicaly Im new to coldfusion.

    Is there a way you can point me the way to see if flash remoting
    is enable in my server?

    Do I need to have any sort of path poting to a folder in the Administrator?

    Or any other ideas?


    THANKS AGAIN
  8. Xerrano
    OK

    My fault 100%

    I place "realestate" folder inside another folder "cfapps" in my "wwwroot"; when I change the "componentPath" variable to "cfapps.realestate" everything worked fine.

    THANKS FOR YOUR TIME
  9. Xerrano
    HELLOW TO EVERYONE

    YOU KNOW IF MYSQL 5.0 CAN BE USE WITH THIS APP?
    The "mysql.sql" file was successfully installed!

    Im getting this error: "Error Executing Database Query."
    is this related to mysql version?

    Thanks
  10. Jorge Tejada

    Jorge Tejada

    Great!, maube you're interested about including AS 2.0 classes in CFForms :-).

    http://www.richinternet.de/blog/index.cfm?mode=entry&entry=DB40A25F-F614-7FEC-F79453ADCC540BA1
  11. David
    Laura or Nahuel,
    Thanks again for this great tutorial! I was wondering how you would handle more than one table, even better two related tables, in a set up such as this. I'm working on a wine application right now where i have wineries (1st table) that produce many wines (2nd/child table) that are used by glass or bottle (3rd/child table). My first thought was to create a seperate interface with each but seems like alot of unnecessary code. My seconde thought was to create a single form that had a grid of all wines, with an accordian below of the winery, wines, and uses, but that seems a little tricky for add/updates. How would you handle a common scenario like this in flash forms? Would love to hear your thoughts! :)
    Thanks again for all your generousity!
    Best regards,
    David
  12. David
    Having trouble getting this to work with my code. I can get my CRUD functions to work just fine accessing them directly or via application variables, but the remoting is throwing me for a loop! When i press the remove button it takes out the record, but it will not give a message nor will it show any items in the grid at all. Same occurs with my inserts and updates except that they don't get added/updated to the database at all. Its like it just resets the grid and thats it. I think it has something to do with the responder and onchange event function of the grid. Can anyone help?
    Here is those two functions that i have:

       public function setUpRemoting():Void{
          <cfoutput><!--- cfoutput to be able to set the gateway dynamically. It is recommended however to write the actual gateway instead --->
             var connection:mx.remoting.Connection = mx.remoting.NetServices.createGatewayConnection("http://#cgi.HTTP_HOST#/flashservices/gateway/");
             var componentPath:String = "#request.componentPath#.services.menuService";
          </cfoutput>
             var responseHandler:Object = {};
             
             <!--- put controls in the responseHandler's scope --->
             var menuGrid:mx.controls.DataGrid = menuGrid;
             
             <!--- handle search by default onResult function --->
             responseHandler.onResult = function( results: Object ):Void {
       
                menuGrid.dataProvider = results;
                _root.setMode('add');
                mx.managers.CursorManager.removeBusyCursor();
             }
             
             <!--- handle create response --->
             responseHandler.create_Result = function( results: Object ):Void {
             
                   if (results.status){
                      menuGrid.addItemAt(0,results.item);
                      _root.setMode('add');
                   }      
                                  
                mx.managers.CursorManager.removeBusyCursor();
                   
                //show a message
                alert(results.message);
             }
             
             <!--- handle update response --->
             responseHandler.update_Result = function( results: Object ):Void {               
                var item:Object = results.item;
                var index:Number = _root.findItem(menuGrid,'MenuItemID',item.MenuItemID);
                if (results.status && index >= 0){
                   menuGrid.replaceItemAt(index,item);
                }
                   
                mx.managers.CursorManager.removeBusyCursor();
                   
                <!--- show a message --->
                alert(results.message);   
             }
             
             <!--- handle remove response --->
             responseHandler.remove_Result = function( results: Object ):Void {               
                
                if (results.status){
                   menuGrid.removeItemAt(_root.findItem(menuGrid,'MenuItemID',results.item.MenuItemID));
                   
                   _root.setMode('add');
                }
                mx.managers.CursorManager.removeBusyCursor();
                
                <!--- show a message --->
                alert(results.message);   
             }
             
             <!--- default error handler --->
             responseHandler.onStatus = function( stat: Object ):Void {
                <!--- if there is any error, show an alert --->
                alert("Error: " + stat.description);
                mx.managers.CursorManager.removeBusyCursor();
             }
             
             <!--- store service in global variable --->   
             form_menuItems.myGlobalObjects.menuService = connection.getService(componentPath, responseHandler );
       }

    and here is the other:

       
       <!--- function that gets called when grid selection changes, used to bind other controls to grid values --->
       public function menuGridChanged():Void {
          
          if(menuGrid.selectedItem == undefined) {
             setMode('add');
          }
          else {
             setMode('edit');
          }
          menuGrid.setFocus();
       }

    I think my remoting function is right:

       <!--- editing / adding a menu item --->
       public function submitEdit():Void {
          var editArguments:Object = {};
          
          <!--- simple text inputs --->
          editArguments.MenuItemID = edit_MenuItemID.text;
          editArguments.MenuItemName = edit_MenuItemName.text;
          editArguments.MenuItemDescription = edit_MenuItemDescription.text;
          
          <!--- checkboxes --->
          editArguments.MenuItemActive = edit_MenuItemActive.selected;
          
          <!--- only make call if all required fields are supplied --->
          if( mx.validators.Validator.isStructureValid(this, 'form_menuItems') ){
             <!--- show clock cursor --->
             mx.managers.CursorManager.setBusyCursor();
          
             if (form_menuItems.myGlobalObjects.isEditMode) {
                <!--- call service --->
                form_menuItems.myGlobalObjects.menuService.updateMenuItem(editArguments);
             }
             else {
                <!--- call service --->
                form_menuItems.myGlobalObjects.menuService.createMenuItem(editArguments);
             }
          }
       }
       
       <!--- removing a listing --->
       public function submitRemove():Void {
          <!--- call service, sending the id --->
          form_menuItems.myGlobalObjects.menuService.removeMenuItem(edit_MenuItemID.text);
       }
    Would greatly appreciate any advice.
    Thanks again,
    David
  13. Steve
    First off-what a great app! I saw this at just the right time for an project that I currently working on developing.

    I modified the code and it works to a point. The gateway returns the query results to the grid. However, I can't get the form or service to pass the arguments to the query.

    I've even tried hard coding the values in the ListingService component to pass to the query, but that doesn't seem to work either.

    Here is my code for the service, gateway and form. Any assistance would be greatly appreciated as this is the only block I have to get this moving.

    Service:
       <cfargument name="teacher" required="no" type="numeric" default="0" hint="Primary key"/>
       <cfargument name="fromDate" required="no" type="string" default="" hint="Search From Date" />

          <!--- call a component sitting in memory (application scope) --->

    Index:
    function submitSearch():Void
    {
       <!--- get all the search criteria items --->
       var searchArguments = {};

       <!--- simple text input --->
       searchArguments.date = search_fromDate.text;
       
       <!--- dropdowns --->
       searchArguments.teacher = search_teacher.value;

       <!--- show clock cursor --->
       mx.managers.CursorManager.setBusyCursor();
       <!--- call service --->
       Homework.myGlobalObjects.ListingService.search(searchArguments);
    }
          <cfreturn application.ListingGateway.search(argumentCollection=arguments) />

    Thanks,
    Steve
  14. Zannie McRae

    Zannie McRae

    Firstly I would like to thank you for all the hard working and great thinking outsie the box. I have remoting working fine but I am having a little problem with consistency. I placed my code inside the form onLoad event and a <CFSAVECONTENT> tag. The tag sets up the remote service and makes a call to a CFC component that reads that database a returns the query / recordset back to the responsehandler function which populates a select drop down with the dataprovider. This works sometimes. When I try to reload the page the dropdown is not populated. I am not sure what the problem can be, but I believe it may have something to do with flash and the dataprovider option. Any information you can provide would be extremely helpful.

    McRae
  15. Josh Rodgers

    Josh Rodgers

    Pretty cool I got everything working, now Im in search of something different.

    I basically want to populate a grid from a query.

    Based on the users selection I then want to go grab more data from another query that joins some tables together and then bind that result to my forminputs, dropdowns etc..

    How in the world do I do that? I am stumped atm.

    please help me :)
  16. Zannie McRae

    Zannie McRae

    I am able to get working fine, but I have a question. I am not able to execute certain actionscript functions within the response handler. For example the getURL function does not respond inside the response handler routine. Is this due to the fact that coldfusion flashforms actionscript does not support user defined functions. Is there any other way of getting the function to fire within the response handler
  17. xerrano

    xerrano

    Is anybody using MySQL 5.0 with this application?
  18. Chaz
    Hi to all

    Laura or Nahuel,

    I have the same problem Xerrano was having.

    This is the error message:
    ___________________________________________
    Error: Service
    Component.RemoteAccess.RDBMSPMAPService not found.
    ___________________________________________

    I've done the solution Xerrano did and I am still having this problem and remoting is enabled on the server.

    This is the setup of the folders under the wwwroot

    wwwroot
    -Component
    --RemoteAccess
    cfc's
    -MainFolder
    --SubFolder
    ---Folder this app
    ----Component
    -----RemoteAccess
    cfc's
    RDBMSPMAPGateway
    RDBMSPMAPService

    I added the components under the app folder to see if this will work, but all of the remote access cfc's are under the root in a folder called component.

    can you help me with this problem.

    Thanks
  19. Chaz
    Laura or Nahuel,

    can you help me with this problem.

    ___________________________________________
    Error: CF Adapter: Service
    _cf_Templates.PMAP.Component.RemoteAccess.
    RDBMSPMAPService does not have method
    "getSummaryResults" that matches the name
    and parameters provided.
    ___________________________________________

    I get this problem when call a component sitting in memory (application scope)

    if i do not call that component and put everything in the first componet everthing works fine.
  20. Josh Rodgers

    Josh Rodgers

    hello there,

    I used a helper function you wrote for the realestate app when handling selections of a cfselect dropdown, I now want to do the same thing with a cfselect listbox (size attribute used) however I am having some issues.

    Heres the code I am using. I hard coded the array, so you know what I am returning, any idea what I am doing wrong, im not a AS wiz:

    var Roles:Array = Array(4000, 4001, 4002);

    <!--- Listbox --note using helper function from below to select right options--->
             _root.selectList(_root.edit_Roles, Roles);



    Helper Function:
          <!--- helper function to select items in a list --->
          public function selectList(select: mx.controls.List, optionsToSelect:Array):Void{
             
             //go through every record to find the right one
             for (var i:Number = 0; i < optionsToSelect.length; ++i) {
                if (select.getItemAt([i]).data == optionsToSelect[i]){
                   select.selectedIndices = i;
                   break;
                }
             }
          }
  21. Xerrano

    Xerrano

    Hellow "Chaz' can you share the solution? or still having problems?

    thanks!
  22. Chaz
    The solution to the wwwroot problems...

    I was looking at the wrong folders.

    The way the site was setup wwwroot is not my root. my root dir is under wwwroot.

    wwwroot
    -component (I put my cfc's here)
    -mywwwroot
    --component (this is were it was looking for them)
  23. Janice
    First of all, great application! I don't think I would have been able to wrap my head around remoting with out it!
    I have build an application similar to this one, only it needs to include a login form and use session variables to ensure that the user is logged in before accessing it.
    I was just wondering if anyone knows of some examples of using flash remoting and a login with session variables. I have found a couple of articles for one or the other but not both and I can't seem to get it working.
    Any help would be greatly appreciated!
  24. Laura
    David,
    It all depends on your application, the amount of data you need to show for each child table, the space you have in the gui, etc. Having everything in one place is good only if it is easy to use, otherwise, it just becomes so complex nobody can use it. At this point, we are leaving the realm of coding to the realm of GUI design and usability, and we believe that GUI is one of the most important factors that can either make an application a success or a failure. Regarding complexity, Flash forms may not be the best way to handle it, as it is difficult to create panels that hide, show, move, etc. So you only have a fixed amount of space to work with. For bigger applications, I would strongly recommend to look at Flex.

    David,
    Can't really tell what your problem is. I would recommend you to start with the sample code that works and start modifying from there to see at what point is stops working.

    Steve,
    First, I am not sure if you have <cfreturn> in the index file or the service. Probably in the service where it should go because you have that part working. Anyway, assuming you have that part right, from what I see, it is sending the teacher but not the date to the service. The properties of the searchArguments object should be named the same as the component arguments. Since you are only passing 2 arguments, you can also use this to avoid using the arguments' names:
    Homework.myGlobalObjects.ListingService.search( search_teacher.value,search_fromDate.text)
    I would also put some trace/alert or something to see if search_teacher.value and search_fromDate.text have the correct values.

    Zannie,
    onload does not work as you may think. Look at this post: http://www.asfusion.com/blog/entry/knowing-when-the-cfform-data-arrives
    Also, there are only a few reasons to use Flash remoting to populate data on onload, since it has the same effect as loading the data normally (specifying a query in the tag directly). Watch out for unnecessarily added complexity.
    Also, try not to use cfsavecontent now that we have functions.

    Regarding your second question, the problem is not that flash forms do not support user defined functions, because after the updater, they do. The problem is the scope. When declaring functions on an object directly like we do when assigning handler functions to the response handler or event listeners, they do not have access to the controls directly. The same happens with other functions, the easiest way to use them is to use _root as in _root.getURL(). There are other ways, like putting the functions into scope like we do for the other controls. Using _root is not very elegant, so I try to avoid it as much as possible.

    xerrano,
    Have not tried mySql 5, but I'll check to see if it is possible

    Josh,
    selectedIndices takes an array, not single numbers. You will have to construct a temporary array in your loop and then assign it to selectedIndices.

    Janice,
    You can reference session variables in your services directly. Flash sends session variables each time it makes a call.



  25. Zannie McRae

    Zannie McRae

    Thanks Laura,

    I looked at the posting of when the data arrives and was able to solve the problem, but as you indicated that it can get a little confusing, so I elected to use the query option of the select component.

    Regards to the second question that worked like a charmed. So I guess it would be best to place everything with scope to avoid _root or scoping problems.

    McRae
  26. Josh Rodgers

    Josh Rodgers

    Wanted to share to helper functions I wrote that handle Listboxes (cfselect tags with size attribute and multiple variables turned on)

          <!--- helper function to select items in a list --->
          public function selectList(select: mx.controls.List, optionsToSelect:Array, arrayLength:Number):Void{
             // start first loop based on array length
             var toSelect:Array = [];
             
             for (var i:Number = 0; i < arrayLength; i++) {
                
                //Next Loop is based on listbox index length - it has 8 indexes
                //go through every record in listbox to
                //find the right ones and select them
                
                for (var z:Number = 0; z < select.length; z++) {
                   if (select.getItemAt([z]).data == optionsToSelect[i]){
                      toSelect.push(z);
                   }
                }
             }
             select.selectedIndices = toSelect;
          }
          
          <!--- helper function to get items selected in a list --->
          public function listResults(select: mx.controls.List, selectionMade:Array):Array {
             // start first loop based on array length
             var fromSelect:Array = [];
             var x:Number;
             
             for (var i:Number = 0; i < select.length; i++) {
                for (var index:String in selectionMade){
                   if (selectionMade[index] == i){
                      x = select.getItemAt([i]).data;
                      fromSelect.push(x);
                   }            
                }      
             }
             return fromSelect;
          }
  27. Scott
    Im trying to add an event listener to a checkbox in a cfgrid. I havent had much luck though. Has anyone had any luck adding an event listener to a cfgridcolumn?
  28. stephenwightman
    I think I might be doing something wrong, but I can't see it...this is the error message I get when trying to launch the index.cfm:

    Attribute validation error for tag CFFORMITEM.
    The value of the attribute TYPE, which is currently "script", must be one of the values: HRULE,HTML,TEXT,VRULE,SPACER.

    The error occurred in C:\CFusionMX7\wwwroot\test\realestate\index.cfm: line 66
    Called from C:\CFusionMX7\wwwroot\test\realestate\index.cfm: line 65
    Called from C:\CFusionMX7\wwwroot\test\realestate\index.cfm: line 1

    64 : <table id="container"><tr><td>
    65 : <cfform name="RealEstateAdmin" format="flash" width="990" height="610" onload="formOnLoad()" style="themeColor:##56A1E1; marginRight:-12; background-color:##37749D;">
    66 : <cfformitem type="script">
    67 : public function formOnLoad():Void{
    68 :

    PS: I'm also very interested in how to implement the same question 'janice' asked - adding a login feature...
  29. Luis Alvarez
    Laura,
    Thanks for you app. Its really allowed me to take cf development in another directions. I'm currently building an RIA that must create tabs in tabnavigator dynamically depending on what accountis chosen in a grid, additionally dynanic fields. I kown Flex has a createchild() function. Any way of doing this in cf7?

    Any direction would helpful.


    Thank you!
    -Luis
  30. Laura
    Scott,
    yes, it is possible. I'll try to make an example when I get a chance.

    stephen,
    You need the CF Updater 7.01 to run this app.

    Luis,
    You can't use createchild, but you could use a repeater instead.
  31. Jen Mostert

    Jen Mostert

    Hi Laura and Nahuel,

    Thank you very much for sharing your code and all of your wonderful knowledge! I can't thank you enough.

    I have one question for you when you have time. I tried using your format for getstate to call a getrace function in my RaceGateway component. I added the correct lines in my application.cfc file and am trying to populate a cfselect just like you did in the Real Estate app. I keep getting an error: The value returned from function getRace() is not of type query.
    If the component name is specified as a return type, the reason for this error might be that a definition file for such component cannot be found or is not accessible. I've looked and looked at the code and everything appears to be spelled correctly and the variables appear to be named correctly. Do you have any suggestions of what I could be doing wrong? Thank you for your time and thanks again for all of your examples. I truly appreciate it.
  32. Jen Mostert

    Jen Mostert

    I'm not sure how I fixed it, but I got it. Thanks again for being such a valuable resource.
  33. thoughtbox

    thoughtbox

    Like a few others, I am getting the error "Error Executing Database Query" when I attempt to submit a search. 7.01 updater is installed, remoting enabled, datasources checked, etc. I see that others have fixed it, but no resolutions have been posted. Any ideas? (WinXP & MSAccess).
  34. Xerrano

    Xerrano

    PROBLEMS WITH MYSQL 5.0 SOLVED WHEN I UPDATE TO MYSQL 5.1.4 ALPHA NOW IS WORKING...
  35. Michele

    Michele

    Thanks for posting such a comprehensive example! I'm having problems getting part 2 to work with MySQL database. Search and remove work ok, but I get the following error when I try to add or update a record: Error executing database inquiry: Unknown Types value. I'm using MySQL ver. 4.1.12. Part 1 ran just fine on MySQL and Part 2 runs ok if I use the Access database. I'm at a loss. Any ideas what could be going on?
  36. Chaz
    Hi Laura and Nahuel,

    My questions are first

    I’m losing my record numbers from displaying when I resize my datagrid.

    i.e.
    with(dgListStandarsReport)
    {
    dataProvider = results;
    selectedIndex = undefined;
    setSize(610,numDataGridTableHeight);
    };//End of with(dgListStandarsReport)

    How do I format number in the datagrid? I using numberformat="999.99", but this is not working.
  37. Jen Mostert

    Jen Mostert

    Just in case anyone else runs into my error above (the value returned is not of type query)...the problem was that I didn't have this line of code: <cfset request.racesGateway = application.racesGateway /> in my OnRequestStart function in my application.cfm file. I know that it is definitely a beginner mistake, but I wanted to post it just in case anyone else has this issue.
  38. Prem
    I know this is not the worst problem to have but I am trying to find a fix. Normally when you set the value property of a <cfinput type="datefield" value="12/10/2004"> for example when you click on the datefield and the calender opens the calender defaults to December 2004 and you can see that the 10th is selected.
    On the other hand when the bind attribute is used the date display changes but when you click on the input field the date selected is todays date.
    Anyone got a fix on this?
    Thanks
  39. Joel
    Is there a way to select multiple records in the datagrid, and then pass the selected records to another page?
  40. Reinhart Jansen

    Reinhart Jansen

    ListingDAO.cfc states at line 7:
    <cfset variables.dsn = arguments.dns />

    shouldn't this state arguments.DSN?

    Btw, thank you so much for the clear examples! I would never have used the Flash version of CFFORM if it hadn't been for you...
  41. Chaz
    I have a question concerning repeaters.

    I need the ability to change results dynamically, how will I do this..

    <cfformgroup type="repeater"
    id="RepeaterIDName"
    query="qRepaterResults"
    startrow="0"
    maxrows="# qRepaterResults.recordcount#"
    visible="yes"
    enabled="yes">

    Thanks
  42. Alex
    I think have litte bug... dont know why, in access have a date and show other date... if in access have 01/27/05 will show 02/27/05

  43. Vincent

    Vincent

    Quick question:
    Will this application work with the Standard Edition or do you need the Professional Edition to use the gateway service and Flash remoting?

    I looked in the doc but I'm kind of confused about the answer I found :-/

    Thanks,
    Vincent
  44. Vincent

    Vincent

    To be more clear about my previous post, I'd like to know the requirements to run this application.

    Obviously this works well with the developer edition but what would be needed if I'd use this technique for a client's project?

    Will the standard edition be enough?

    Thank you so much for this tutorial. It's awesome!
    Vincent
  45. arija
    Please continue to post projects like this here instead of IFBIN.
  46. Sakang
    I have an extremely long, multi-step flash form. Each step is divided into a tab. Due to the long nature of the form it
    it enables the user to come back and finish the form at a later time. I have already implemented this form using a traditional
    html form. The way I implemented it in a traditional form approach is that I submit the form and save the data into
    the database upon submitting it. (Each step comprises one form so there are total of 5 forms in the application.) When the user
    comes back to finish filling them out, I just simply goes back to the DB and retrieve the data and pre-filling the parts the user
    already filled out then continue with the rest.

    Now I wanted to convert the form into flash form with Flash Remoting that will allow the using to submit and retrieve
    data without leaving the form. I have arranged the form into tab interface, each tab equals to one step. There are five
    tabs total. I am able to submit the form and retrieve data back using flash remoting. However, the biggest challenge I am
    facing is how can I submit only parts of the form? I need to be able to distinguish which part of the form controls I am
    submitting and which controls I need to validate before I submit and store data. In the traditional form, it was easy
    because each step was its own form so I could only apply appropriate validations and required fields on the appropriate
    appropriate form and only submit that form data to DB. However, since this flash form version is only a one, continues form
    all controls will be submitted and all required fields will try to validate eventhough you are only submitting parts of it.

    Does anybody have an advise on how I can make this work with the flash form using the same implementation i have in the traditional form.

    thanks everyone!


  47. Adrian Showalter
    This was my first experiance with Flash forms, and because of your tutorial I was able to unlock all kinds of secrets that the CF docs either don't address (or intentionally hide?). Thanks for the great tutorial. I've been in awe of your work ever since we found the Metal Tracer app, which served as our inspiration to use Flash as our primary development platform. Keep it up! You make the impossible possible for the rest of us!
  48. Jeff Bouley
    Janice,

    Please see my blog to integrate session management into your flash form application. I think my code is what you're looking for:
    http://blog.strikefish.com/index.cfm?mode=entry&entry=EC1E92BC-CF0D-5F0F-C6B1FE5B951D85A9
  49. Vincent

    Vincent

    I really like this app and now use it to make another app.

    One minor thing however:
    - when the form is submitted (add or update), is there a way to validate using alerts in addition to the error messages in the field?

    Basically, I'd like to get the same function as the "onsubmit, on server"

    Even though all my fields have "validateat="onsubmit, onserver", the alert box doesn't show up when validated.
  50. Adrian Showalter
    Vincent,

    I did this by adding

    if( mx.validators.Validator.isStructureValid(this, 'YourFormName') ){
    // do submit or remoting here
    }

    to the function called when the submit button is pressed. I think that will do what you are looking for.
  51. Vincent

    Vincent

    Hi Adrian,

    that's what I currently have.

    The problem is that the validation is made in the fields but not as an alert even if each field is assigned the "validateat:onsubmit, on server"

    My understanding is that the function bypasses the "validateat" but I don't know how to call it in ActionScript.

    Vincent
  52. Vincent,
    I used the code below and it seemed to work pretty well. Hopefully it will help you out.

    if( mx.validators.Validator.isStructureValid(this, 'yourformname') ){
    mx.managers.CursorManager.setBusyCursor();
          
    var errCount:Number=0;
    var errMessage="";
    var isOk:Boolean=true;
          
    if (_root.fieldname.length == 0) {
    errCount=errCount+1;
    errMessage=errMessage+"("+errCount+") Error message text here...";
    isOk=false;
    }
    if (_root.2ndfieldname.length == 0) {
    errCount=errCount+1;
    errMessage=errMessage+"("+errCount+") Error message for 2nd field here...";
    isOk=false;
    }
    if(not isOk) {
    errMessage=errCount+" form error(s) found.\n\n"+errMessage;
    alert(errMessage, "Warning");
    mx.managers.CursorManager.removeBusyCursor();
    }else{
    //do remoting here
    }
  53. JDB
    First off. Great App and thanks for the excellent tutorials.

    Any idea why I would be getting the following error when clicking on the 'search' button:

    "Service threw an exception during method invocation: null"

    Thanks!
  54. Bytor
    Thank You! Thank You! Thank You!

    I've been a CF developer for about 5 years now and stumbled upon this site and OH BOY did it lite a fire under my butt!

    Thanx to your excellent tutorials and examples, I have whipped out an app in the past 4 days.

    http://www.bytorproductions.com/projects/work/products2/

    Next step, getting the bad boy to update via remote calls!

    Keep up the great work!
  55. Brian Hudson

    Brian Hudson

    I have tried this application on my own server and everything works great except for one thing. When I run a search the second time, nothing happens - nothing appears in the cfgrid. I have to reload the page to do another search. Any ideas?

    Thank you very much for taking the time to put this tutorial and sample application together. I have learned a lot working with it this past week. Your website is so full of useful information. Your efforts are greatly appreciated!
  56. Brian Hudson

    Brian Hudson

    Ignore my problem in the previous post. I solved it. I was sending an incorrect default value for a radio button which produced a query with no results to display.
  57. Kevin
    Looks good and is ideal for a current project I'm working on. But I'm unable toget it running locally on my machine, managed to get part 1 working fine though.

    I keep getting the following message:

    Data source RealEstate could not be found.


    The error occurred in C:\Inetpub\wwwroot\realestate\components\StateGateway.cfc: line 16
    Called from C:\Inetpub\wwwroot\realestate\index.cfm: line 6
    Called from C:\Inetpub\wwwroot\realestate\index.cfm: line 1
    Called from C:\Inetpub\wwwroot\realestate\components\StateGateway.cfc: line 16
    Called from C:\Inetpub\wwwroot\realestate\index.cfm: line 6
    Called from C:\Inetpub\wwwroot\realestate\index.cfm: line 1

    14 :    <cfset var q_state = "" />
    15 :    
    16 :    <cfquery name="q_state" datasource="#variables.dsn#" cachedWithin="#CreateTimeSpan(0,2,0,0)#">
    17 :       SELECT   state.*
    18 :       FROM   state
  58. Kevin
    Go it sorted now, but what I would like is some help getting two related selects working on the seaech. I've had a look at the examples of this on here but can't get it working with a query for each select. Also the selects aren't related by an id, just related by descriptions of different areas.
  59. jgamma
    First off, I love your site. I can usually find an answer to all of my questions without ever asking. Which is probably the case now as well, except I'm so frustrated.

    I'm using CFMX7 Developers edition on my local machine. I've created my own, downloaded apps I know work, copied and pasted you name it and NOTHING using flash remoting works.

    I've reinstalled CF twice now and I can not find ANYTHING about flash services gateway in the adminstrator or file structure anywhere.

    Where can I look to see if in fact it is installed and if not where can I get it from. I've been a Coldfusion Developer for quite some time but these are my first efforts at Flash Remoting.

    Sorry if this is completely stupid but I'm at a loss.

    Thanks
  60. jgamma
    Well I found this to answer part of my question I thought I'd post it in case anyone else had the same thought. Still can't figure out why it won't work, though.

    "The Flash Remoting service URL does not translate to an actual directory structure on your web or application server. The URL, which ends in flashservices/gateway, specifies the web application context and gateway servlet mapping for the Flash Remoting service." http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_16319#url


  61. jgammache

    Sorry I'm such a dope I need to read more carfully! Well if anyone else out there is having this problem and missed it the 100 other times it was posted. Your CFC needs to be as viewed from the root for example I had my flRemote.cfc stored in a file called remoting in the root of my site. ex:
    myService = connection.getService("remoting.flRemote", responseHandler );

    Sorry for all the posts
  62. BFLOPHIL

    BFLOPHIL

    "Service threw an exception during method invocation: null"

    I get the same results when using the search button. Would anyone have any suggestions?

    Thanks
    Phil

  63. Micah Knox

    Micah Knox

    Has anyone installed this application on a public web server and tried to access it via the public domain name. For example, I have no problems with flash remoting when accessing my sites via the localhost domain but when I deploy the code to our development server and try to go out over the internet and view the application, it doesn't seem to work. I don't get an error message and sometimes it will even return query results from the component, but most of the time I just get a blank screen. Has anyone ever run across this before? Thanks.

    Micah
  64. MJE
    Hello,

    First, thanks for all of the hard work on this application! It has been absolutely invaluable to me!!

    I am encountering one issue with the app itself using MS Access - I receive the following error when attempting any searches: Im getting this error: "Error Executing Database Query." - everything else works.

    Second issue is, you know how if you have a regular submit button, all of the messages that you enter in required fields pop up. However, using the type="button" to call the function to submit without refresh doesn't show those messages, although it highlights the required fields. How can I get the messages to display?

    Thanks again!
  65. MJE
    Hello again,

    Has anyone been able to get this to work with Access? I don't have MySQL to see if that is the issue, but when I install this right out of the gate, everything works except for the search functionality. Every time I hit the search button, I get Error Executing Database Query. I desparately need to utilize this search functionality, and trying to troubleshoot this by taking all of the queries out of the listingDAO.cfc didn't work. I see that hte search function calls the listingService.cfc which then in turn calls the listingGateway.cfc, but trying to take out the queries and params to determine where the issue is located hasn't gotten me anywhere.

    BTW - what does DAO stand for in the listingDAO.cfc file?

  66. MJE
    Ok, I found the cause of the "Error Executing Database Query" thingy. When I commented out the line:
    searchArguments.bathrooms = search_bathrooms.selectedItem.data;
    on the index.cfm page, the search worked! I'll have to look a little further to see why that is, but I'm so glad that I finally got it working. One less question of mine to answer :) Again, WONDERFUL job on all that you're doing here!
  67. Laura
    MJE,
    When using access, make sure your datasource is using Access with Unicode (as opposed as just Access), otherwise some cfqueryparams don't work.

    DAO stands for Data Access Object
    :)
  68. MJE
    Hi again,

    Quick question (I hope) - I'm having some issues with having the updates, deletions and new item inserts showing up in the datagrid after posting. I've managed to get the creation, search and edit to work (mind you this is not the actual real estate application, but an application that I've been building using this as a reference).

    I've been going over and over the code and am not sure what I'm missing. I have the listing grid change function there, but I'm not seeing/understanding the code in the real estate application that updates the listingGrid datagrid when something is added, edited or deleted, but it does work in your example.

    Could you please give me a quick pointer as to what I should be paying attention to?

    Thanks!
  69. David
    MJE,
    You might want to double check your DAO's fetch method. If you don't include all the fields that are in the grid, then they won't show up. I had the same problem because i was using a joined query in my grid and half wouldn't show up because i wasn't querying all the fields in my fetch method after my insert/update. Hope this helps!
    David
  70. MJE
    Thanks for your input David,

    I went into the fetch method, and wasn't sure exactly where I should be focusing with regard to including all the fields that are in the listingGrid. I ensured that all of the lines that have <cfset data["mls_id"] = getQuery.mls_id /> for example, all correspond to the items in the listing grid.

    Do you mean that all of these cfset data lines should correspond to all of the form fields that are in the cfform in order for the real time updates and additions to reflect in the data grid?

    I am able to search successfully - it is just when I make an edit or add a new record. The edit and and addition does take place in the database, it just doesn't show up in the data grid until I manually refresh the page.
  71. David
    MJE,
    Whatever fields you have in your grid, your fetch method must contain the same. I don't think that is your problem though now that you mention that when you refresh the grid has the new value. Instead, look in setUpRemoting() and make sure that your onResult, create, update and remove methods are correct. These are what update the grid once your fetch methods send data back to the service. These methods should match those that are in the service followed by _Result. Ex: serviceName_Result. In my case i have a service called createImage so when i want to get the result entered back to my grid i use the responseHandler.createImage_Result in order to have it sent to my grid:

          <!--- handle create item response --->
          responseHandler.createImage_Result = function( results: Object ):Void {
          
                if (results.status){
                   imageGrid.addItemAt(0,results.item);
                   _root.setMode('add');
                }      
                               
             mx.managers.CursorManager.removeBusyCursor();
                
             //show a message
             alert(results.message);
          }
    Hope this helps,
    David
  72. Alex
    hi,

    I'm just windering if there is a way to see an error returned by flash form page? Is there any debuging method available for flash forms?
    I pretty much disassemble your code and re-created similar application, but there are some weird point I'd like to check and can't see what's happening from CF point of view.

    Thanks for any info!
  73. SIMON DONN

    SIMON DONN

    When a user logs in I set a struture with a list of regions , each region has its own tabbed page and grid. I pass the grid name to a function which passes it through to the cfc and returns the query and gridname to be updated.

    now this is where my problem starts

    if I alert('mailbox name:' + results[0]); then I get australia which is the mailbox region but how do i replace this statement with one using the dynamic name.

    var Australia:mx.controls.DataGrid = Australia;
    Australia.dataProvider = results[1];

    I've tried everything but nothing works.

    i.e
    var results[0]:mx.controls.DataGrid = results[0];
    results[0].dataProvider etc.

    any ideas?
  74. Hi all

    I've successfully converted this app to my own usage. However, I'm a bit at odds about changing how the ID/Primary Key is implemented, because the realestate app uses a string (MLS_ID) instead of a more typical autonumber.

    I've just about caught everything except for the Create functions in ListingService and ListingDAO. Where exactly is the code that re-lists the grid, but uses the newly inserted ID only?

    In other words, I don't see a re-query after the Insert SQL, because in the case of the realestate app, the primary key has basically been TYPED by the user as the MLS ID. In my application, the ID is created by the DB (MS Access), so while the app does insert the data, it still comes back with an error since the listing is not showing the newly entered listing.
  75. Scott
    Alex,

    I used a default (user friendly) error message inside of the CFCATCH tags and then included a cfmail tag that has all of the error information and data dumps.

    Scott
  76. Scott
    The following link explains how to enable flash remoting on multihomed Microsoft IIS servers:

    http://www.macromedia.com/support/flashremoting//ts/documents/iis_gateway_connection.htm
  77. SIMON
    Scott, how you do you include a cfmail tag in the actionscript?
  78. Scott
    Simon,

    There are three try an catch error handlers on the ListingDAO.cfc file. You can add the cfmail tag inside the <cfcatch></cfcatch> blocks.

    EXP:

    <cfcatch type="Any">
             <cfset returnObj["status"] = false/>
             <cfset returnObj["message"] = "Generic error message that you want the user to see"/>
             <cfmail to="[email protected]" from="[email protected]" subject="Error">
             #CFCATCH.message# : #CFCATCH.detail# <BR />
             
             Then whatever generic message that you want to include. I also include the data dumps.
             </cfmail>
             
          </cfcatch>
  79. SIMON
    thanks for that scott, but when my application times out then you cannot access any components so i was interested in a mail tag that can be used within actionscript.

    <cfset application.listingGateway = createObject("component",variables.componentPath & ".components.ListingGateway").init(variables.dns) />

    Is there a better way of doing this then in the application scope?

    great site, keep up the good work!!!
             
  80. Scott
    Do you have a site wide error handler?

    If so, you can use the cfmail in there.

    I also use cfmail tags on my application page for unexpected log-outs.

    I am a newbie to actionscript, and I really don't know of a way to use the mail tags inside of the actionscript.
  81. Ray Buechler

    Ray Buechler

    Hopefully someone will be able to help me out here. I've modified the Real Estate app to fit my own needs.

    I've pretty much got everything working (adding, updating and deleting a record). However two things are not happening, first, a record is created, updated or deleted the grid goes blank. I have to refresh the browser to get the grid data back. Second, there is no status message after a record is added, deleted or updated. The main change I have made is that I am not using the search piece of the Real Estate app. Other than that the actionscript code is straight from the Real Estate app.

    Any help would be greatly appreciated.

    Ray
  82. Melissa

    Melissa

    How can you eliminate the "click to activate this control" for cold fusion flash forms in IE? We have a fix for flash forms but the fix will not work for cold fusion flash forms.

    Thanks.
  83. Laura
    Melissa,
    There is no fix for that yet.
    http://www.forta.com/blog/index.cfm/2006/4/17/ColdFusion-And-IE-Active-Content-Changes
  84. Doug Bedient

    Doug Bedient

    I have been playing with this code trying to set up a simple datagrid and form using the example files. The problem I keep running into is the following error.

    Cingular.services.listingService does not have a method "remove" that matches the name and parameters provided.

    Here are the chunks of code:

    =============================

    public function submitRemove():Void {
    alert(edit_cing_ID.text); <!---good--->
    cingularAdmin.myGlobalObjects.listingService.remove(edit_cing_ID.text);
    }

    =============================

    <cffunction name="remove" access="remote" returntype="struct" output="false" description="Removes a listing">
       <cfargument name="cing_ID" required="true" type="numeric" hint="Primary key"/>

          <cfset var result = application.listingManager.delete(arguments.cing_ID) />
          <!--- item will only contain the id --->
          <cfset result["item"] = structnew()/>
          <cfset result["item"]["cing_ID"] = arguments.cing_ID />
          
          <cfset result["status"] = javacast("boolean",result["status"]) />
          
          <cfreturn result />
          
    </cffunction>

    =============================

    <cffunction name="delete" output="false" hint="Deletes a listing" access="public" returntype="struct">
       <cfargument name="cing_ID" required="true" type="numeric" hint="Primary key"/>

          <cfset var deleteListingQuery = "" />
          <cfset var returnObj = structnew() />
          <cfset returnObj["status"] = false />
          <cfset returnObj["message"] = "" />
          <cfset returnObj["cing_ID"] = arguments.cing_ID />

       <cftry>
          <cfquery name="deleteListingQuery" datasource="#variables.dsn#">
    DELETE FROM cingular
             WHERE cing_ID = <cfqueryparam value="#arguments.cing_ID#" cfsqltype="cf_sql_integer" maxlength="10"/>
          </cfquery>

          <cfset returnObj["status"] = true/>
          
          <!--- catch any error that the query may have thrown --->
       <cfcatch type="Any">
          <cfset returnObj["status"] = false/>
        <cfset returnObj["message"] = CFCATCH.message & ": " & CFCATCH.detail />
          </cfcatch>
       </cftry>
                      
       <cfif returnObj["status"]>
       <cfset returnObj["message"] = "Listing has been deleted"/>
    </cfif>

       <cfreturn returnObj/>
    </cffunction>

    ================================

    I've been starring at this a long time. I would really appreciate any help.
    Thanks,
    Doug
  85. Doug Bedient

    Doug Bedient

    A little more info. I ran the page with a HTTP analyzer and the only difference I could see was an extra ' and an additional . Do I have something wacked? Anybody have an idea where? Are people still viewing these messages? Thanks.

    Your demo:
  86. Doug Bedient

    Doug Bedient

    Maybe a bug-n-da-blog? It keeps cutting my posting off.

    Your demo:
  87. Laura
    Doug,
    I don't know why your comment got cut. Maybe you tried using a code tag and didn't close it?
    Anyway, back to your problem. I've seen that, but I can't recall what was the cause. I would make sure the application scope does not have an old instance of the component you are trying to access. I would also remove the body of the functions in the component and see if any of that fixes it (in the case there is an error there). Just in case, first I would also cast the parameter you send to the remote function as a Number.
    I am glad you are using an HTTP analyzer to debug your code. I see a lot of people just working in the dark when it comes to debugging remoting.
  88. Chaz
    What is a HTTP analyzer? and how do in get it?

    Thanks
  89. Doug Bedient

    Doug Bedient

    Here's the link. I'll let them explain it.

    www.ieinspector.com/httpanalyzer/
  90. Jeremy
    Real estate sample app - very cool!

    works great locally

    not so good once uploaded to my host.

    search fails when checkboxes are checked. ("Error executing database query")

    add / update property fails. ("Error executing database query: unknown types value")

    i'm running mysql 5.0.18 on both. any ideas?

    thanks,

    Jeremy



    i've seen some posts regarding this problem
  91. Laura
    Jeremy,
    I would say that your local machine and your host have difference JDBC drivers since it works in one but not the other. The latest drivers usually work better than the old ones.
  92. Chaz
    Hi to all

    I found away to pop up a window in cfform, but I am having problems with it need some help.

    This is the code:

    function ErrorPopUpScreen():Void
    {
    var PopUpWindow = mx.managers.PopUpManager.createPopUp(_root,mx.containers.Window,true);
                PopUpWindow.closeButton = true;

    _global.ClosePopUpWindowBtnListener = Object();
    _global.ClosePopUpWindowBtnListener.click = function(EventObject)
    {PopUpWindow.deletePopUp();
    };//End of ListenerDataLoaded.modelChanged = function(EventObject)
    PopUpWindow.addEventListener("click",_global.ClosePopUpWindowBtnListener);

    PopUpWindow.setSize(660,340);
    };//End of function ErrorPopUpScreen():Void

    the window shows up… it shows up as transparent (even the content is transparent). I can not add a title and if I close the window and reopen it.. the close button moves off to the side of the window.

    Can anyone help me with this…
  93. Kelly
    I have my update script working, but when it calls the replaceItemAt function on the datagrid it is removing all data from that line. Is this where the fetch function comes in? If so, where does it go? All I want is to update one column in the grid...

    I read in the Part 2 article about the fetch function and how "This structure will later be used to poulate the created or updated records in the datagrid." I see how this is working in your sampel app, but I am not seeing where it is called to do that.
  94. Kelly
    I figured out the fetch function. This is what my response handler looks like...The item.getLength returns 1 - which should be the record count (i am assuming). But when I refer to item.ESS_TEXT (ess_text is a column in the query) i get nothing. The index (finding the correct item in the grid) is working, the status and message are working, but I just can't get the data back into the grid. It appears there is a problem reading the data. Any ideas for debugging or solving the problem. Let me know if I need to provide more data.

    responseHandler.saveEssEval_Result = function( results: Object ):Void {         
    var item:Object = results.item;
    alert("item length " + item.getLength());
    alert("col names " + item.getColumnNames());
    alert("ess " + item.ESS_TEXT);
    alert("res ess_uuid " + results.ess_uuid);
    //find the item's index      
    alert("index " + index);      
    var index:Number = _root.findItem(essentialsGrid,'ESS_UUID',results.ess_uuid);   
    if (results.status && index >= 0) {         
       essentialsGrid.replaceItemAt(index,item);
       alert("Item updated");
    }
    else {
       alert("grid could not be updated");
    }
          mx.managers.CursorManager.removeBusyCursor();
    }
  95. Laura
    Kelly,
    Almost guaranteed that is a case-sensitivity problem. Check that the keys of your structure match the case of those in your grid column (not what you write as the column name but the case of the column in your query). Note that if you use Oracle all columns are upper case, or at least that is what people have reported.
  96. Boybles

    Boybles

    Laura,
    I'm still trying to grasp why in this example you never use cfsavecontent for anything, yet in many examples throughout this site you do. What would be the main impetus for using actionscript contained in cfsavecontent vs. using actionscript contained in the form (<cfformitem type="script">). Additionally, I noticed that your listener (event: modelChanged) examples (knowing when data arrives in grid) never use cfsavecontent. Why is that?
    Thanks!!!
    Boybles
  97. Laura
    Boybles,
    If you look carefully, you will notice that all of the examples that use <cfsavecontent> are previous to the release of the CF Updater that added the <cfformitem type="script"> functionality. With the new feature of being able to create your own functions, there is no reason to use <cfsavecontent> and therefore functions should be used instead. See this post: http://www.asfusion.com/blog/entry/filtering-a-grid-as-you-type---using
  98. Kelly
    I have setup flash remoting for a form on another page using the same syntax and it works, but on a different page I am getting the following error...
    "There is no property with the name 'manageGoals'."


    It is failing on my formOnLoad function where I am creating a new object...
    manageGoals.myGlobalObjects = {};

    Any ideas??

    Kelly
  99. Laura
    Kelly,
    "manageGoals" needs to be the name of your form. If you change the name, you need to update the global variables to use the new name.
  100. Kelly
    Sorry! I completely forgot about that.

    Kelly
  101. Gilbert
    Hello all, you did a great job on this sample application.
    I took it and tried to adapt it for my purpose, a server manager tool. Everything works well except one problem:

    I display all my servers in a grid and the user can see the details of the server in a box below the grid. All the bindings work as expected. Once I have done a search to minimize the number of displayed servers in the grid all the bindings work okay but not the checkboxes.
    For example the binding is done like this:

    <cfinput type="checkbox" name="serv_hosted" label="hosted" value="{listingGrid.selectedItem.serv_hosted=='true'}"/>

    The problem is that nothing is selected even if the checkbox is checked inside the grid !

    Can someone please help me as I am totally clueless waht happens here.
    Thanks
  102. Stace
    How do you clear a default value from a text input in flash forms, like onClick or onFocus ?
    Or is there anouther angle of attack to take with this?

    Thanks All
  103. Dan
    I've been working on an app based on your code and I have a question. Basically I'm working on an app where you can record vacation and at the top it lists current usage and remaining vacation hours. These are not in form fields, they are only text.

    Is there a way to update these text items when an item is updated, added or deleted from the grid, which holds the vacation log? Do I have to put these values into cfinput fields?

    Thanks for any advice and the sample app.
    Dan
  104. Dan
    Never mind. I found your blog on changing text for cfinput lables and just used the cfformitem tag.

    Dan
  105. James McArdle
    <cfsavecontent variable="test">
    requiredfieldname.parent.indicator_mc._alpha=0;
    </cfsavecontent>

    Above is the solution to the astericks of doom problem. feel free to email me if you have any questions. enjoy everyone!
  106. Laura
    Gilbert,
    There are examples for checkboxes in the article, although those work when the grid does not show the checkboxes. It looks like this:
    <cfinput type="checkbox" name="edit_hasPool" value="{(listingGrid.selectedItem!=undefined)?listingGrid.selectedItem.hasPool:false}" label="Pool"/>

    Also note that there are bugs when that grid column is editable as noted in this post: http://www.asfusion.com/blog/entry/binding-checkboxes-in-flash-forms

    Stace,
    To clear the value use: myTextInput.text = ''
  107. Steve Walker

    Steve Walker

    In place of the mls_id I want to use a UUID, but I cannot figure out where to place CreateUUID() to dynamically create one when I fire the create() function.
  108. Dan Fredericks

    Dan Fredericks

    I have a cfselect box which lets the user select multiples. I need to take that data, and pass it to a cfc, so I can get data from the database, and then use that data to display a certain amount of checkboxes.
    I can't seem to put together the data using actionscript from the select box.

    <cfselect enabled="yes" name="Schedule" multiple="yes" size="5" width="95" label="">               
                      <!--- <option value="select">Schedule</option> --->
                      <cfoutput>
                      <cfloop query="schedules">
                         <option value="#scheduleID#">#schedule#</option>
                      </cfloop>
                      </cfoutput>
                   </cfselect>

    actionscript:(in a cfsavecontent tag)
    I have flash remoting code, but need to pass the values from the above select list.

    any help?

    Thanks
  109. Alan
    Hi

    Excellent tutorial.I came across some of the problems mentioned above and resolved them and managed to resolve them to RealEstate App to run.

    I then tried to create my own application based on the tutorial I get the following error when I click my search button:-

    Error: Element DOCUMENTGATEWAY is undefined in a Java object of type class [Ljava.lang.String; reference as...

    I have defined within the application.cfc the following..

    <cfset application.documentGateway = createObject("component",variables.componentPath & ".components.DocumentGateway").init(variables.dns) />

    Any ideas?
  110. Alan
    Hi

    I've resolved previous comment - restarted CF.

    thanks
    Alan
  111. Laura
    Steve,
    I would put the createUUID() in the create function of the ListingDAO before making the insert query. Then, when you return, set the returnObj["mls_id"] with the newly generated id.

    Dan,
    You have to loop over the selectedIndices of the List (cfselect) and send that to the cfc in some form you choose (you can create an array with ids, a list, etc), but you have to make your cfc accept that array, list, etc.
  112. Dan Rouw

    Dan Rouw

    I'm working on an application based on your sample code. It is a PTO (Paid Time Off) application, so I have a tab for each month and a cfgrid on each tab. I have the code working to create/update/delete entries, but my one hang up is that I need to update the correct cfgrid dynamically instead of hardconding the grid name into the response handlers. I'll paste my response handler code below. In both cases the database is being updated correctly.

    Thanks for any advice you have.

    Dan

    <!--- handle update response - This code does not update the grid. The value of results.gridName is 'AugPTO' --->
    responseHandler.updatePTO_Result = function ( results:Object):Void {

    if (results.status) {
    var item:Object = results.item;
    alert(results.gridName);
    var grid:mx.controls.DataGrid = results.gridName;
    var index:Number = _root.findItem(grid,'PTOID',results.PTOID);
    grid.replaceItemAt(index,item);
    }
    mx.managers.CursorManager.removeBusyCursor();

    alert(results.message);
    }

    <!--- handle update response - This code does update the grid. AugPTO is the name of the grid for August. --->
    responseHandler.updatePTO_Result = function ( results:Object):Void {

    if (results.status) {
    var item:Object = results.item;
    var index:Number = _root.findItem(AugPTO,'PTOID',results.PTOID);
    AugPTO.replaceItemAt(index,item);
    }
    mx.managers.CursorManager.removeBusyCursor();

    alert(results.message);
    }
  113. Dan Rouw

    Dan Rouw

    Well, I've come up with a solution, although it is not as eligant as I had hoped. If anyone can help me improve on this I'd appreciate it. I tried using arrays and creating an object, but it seems like I am not allowd to cast the items in the array and object to mx.controls.DataGrid.

    Here is the code that works. If no one has any suggestions for improvement I'll leave it as is.

    Thanks,
    Dan

    <!--- handle update response --->
          responseHandler.updatePTO_Result = function ( results:Object):Void {
             
             if (results.status) {
                var item:Object = results.item;
                switch (results.gridName) {
                case "JanPTO" :
                   var grid:mx.controls.DataGrid = JanPTO;
                   break;
                case "FebPTO" :
                   var grid:mx.controls.DataGrid = FebPTO;
                   break;
                case "MarPTO" :
                   var grid:mx.controls.DataGrid = MarPTO;
                   break;
                case "AprPTO" :
                   var grid:mx.controls.DataGrid = AprPTO;
                   break;
                case "MayPTO" :
                   var grid:mx.controls.DataGrid = MayPTO;
                   break;
                case "JunPTO" :
                   var grid:mx.controls.DataGrid = JunPTO;
                   break;
                case "JulPTO" :
                   var grid:mx.controls.DataGrid = JulPTO;
                   break;
                case "AugPTO" :
                   var grid:mx.controls.DataGrid = AugPTO;
                   break;
                case "SepPTO" :
                   var grid:mx.controls.DataGrid = SepPTO;
                   break;
                case "OctPTO" :
                   var grid:mx.controls.DataGrid = OctPTO;
                   break;
                case "NovPTO" :
                   var grid:mx.controls.DataGrid = NovPTO;
                   break;
                case "DecPTO" :
                   var grid:mx.controls.DataGrid = DecPTO;
                   break;
                default :
                   var grid:mx.controls.DataGrid = JunPTO;
                }
                var index:Number = _root.findItem(grid,'PTOID',results.PTOID);
                grid.replaceItemAt(index,item);
             }
             mx.managers.CursorManager.removeBusyCursor();
             
             alert(results.message);
    }
  114. Steve Walker

    Steve Walker

    Laura,

    Thanks. The UUID is generated and inserted into the database without any problems, but then the fetch function throws an error saying that the data being sent is not of the type UUID. If I change it to type=string it works except the fetched record is blank and I have to refresh the form in order to see the new record. Any ideas?
  115. Sam
    I have the same problem using the autonumber for the mls_id for the insert,update and delete.

    Can anyone help me on how to implement the records maintenance following this example using autonumber as the primary key.
  116. 6dust
    I've really fallen in love with Flash Remoting via CFForm, but have hit a bit of a snag. I am trying to setup an application that polls the server every once in a while via setInterval. The non-remoting code in the repeating function executes fine, but it doesn't look like my remoting is every really called. Any ideas?

    Code:
    <cfform onLoad="doneLoading();" height="400" width="350" format="flash" method="post" name="jakarta_form1" style="background-color: ##398A8E; color: black; theme-color: ##4CB2B8;">
       <cfformitem type="script">
          var jakartaService:mx.remoting.NetServiceProxy;
          
          function doneLoading()
          {
             setRepeat();
             setupJakartaService();
          }
          
          function setRepeat()
          {
             _global.myInterval = setInterval( repeatedCheck, 5000 );
             _global.myCounter=0;
          }
          
          function repeatedCheck()
          {
             _global.myCounter++;
             jakartaService.getTimeStruct();
          }
          
          function setupJakartaService()
          {
             var connection:mx.remoting.Connection = mx.remoting.NetServices.createGatewayConnection("http://<cfoutput>#cgi.HTTP_HOST#</cfoutput>/flashservices/gateway/");

             var responseHandler:Object = {};

             responseHandler.getTimeStruct_Result = function( results: Object ):Void {
                alert(results.DATE_STRING);
             }
             responseHandler.onStatus = function( status: Object ):Void {
                //if there is any error, show an alert
                alert("Error: " + status.description);
                mx.managers.CursorManager.removeBusyCursor();
             }
             jakartaService = connection.getService("Jakarta.backend", responseHandler );
          }
          
          
          function onSubmitClick()
          {
             progressBar.visible = true;
             progressText.text = "Submitting request...";
             jakartaService.getTimeStruct();
          }
       </cfformitem>


    If I click the button that calls onSubmitClick(), the remoting call runs fine and I get a string alerted to me, as it should be. However, the call via setInterval never executes. The _global.myCounter variable gets incremented, so I know that portion is working...

    Any thoughts would be greatly appreciated!

    Thanks,
    6dust
  117. thomary

    thomary

    I have the same problem using the autoincrement for the mls_id in a MySQL database.

    Can anyone help us on how to implement the records maintenance following this example using autoincrement as the primary key.
  118. 6dust
    D'oh!

    Mine was a scoping issue; just figured it out. I changed it from this:
    _global.myInterval = setInterval( repeatedCheck, 5000 );
    to this:
    _global.myInterval = setInterval( this, "repeatedCheck", 5000 );
    and now it works fine.
  119. aubry
    hello
    I m trying to make a cf application based on the realestate sample but when I try to update, remove or insert new data I've this error message :
    Error : CF adapters : Service form.services.ListingService does not have a method "updateRoomok" that matches the name and parameters provided.

    Please, help mee I' going crazy about this


    thanks !!!

    ps : if someone want to help me I can sent him my files
  120. Rob
    I've been reading over some of the great examples on this site about flash remoting.

    I constructed a small search box, that fills a grid - and that works great.

    I'm trying to show phone numbers for the selected person from the grid, and thought a repeater would work well for this.

    When someone clicks on an item in my grid, it does a flash remote query to pull back all the telephone numbers a person has (voice, fax, mobile etc).

    I get the query back, but can't figure out how to get the repeater to change to show the results.

    I've got a handler setup, and it executes when my data comes back, and I've tried to do something like this:

    q1.dataProvider = results;

    q1 being the query holding the telephone numbers. This does not give me any error, but the repeater does not update.

    What am I missing?
  121. xavy
    Hi Laura,

    Excellent tutorial. I was able to do get most of the functionlity working for my app. I have one problem though - I am not able to see the changes in the grid after an update - the reason being the code is not able to get the index of the row updated:

    responseHandler.update_Result = function( results: Object ):Void {
    var item:Object = results.item;
    var index:Number = _root.findItem(listingGrid,'mls_id',item.mls_id);

    Here if I check the item.mls_id, I do see the ID that was upadted, but the findItem returns nothing and hence the grid does not get updated - everything else works just fine. Any idea what I am doing wrong? Any help will be greatly appreciated.
    Regards,
    Xavy
  122. Laura
    Rob,
    Use the name of the repeater instead of the name of the query to set the results of the remoting call.

    xavy,
    I am not sure what the problem can be, but I would check the case of the column names.
  123. Stacy
    I am having a problem on a form I'm working on, and it looks like the same problem might exist in the Real Estate App as well...

    I have a text field in my form that is for a dollar amount. the dollar amount can be from .01 up to 4999.99. The problem I'm having, is that it will accept a number such as 20.023546, which isn't valid. I was able to put a similar number into the real estate app when adding a new property for the price.

    How can I do an actionscript validation that will look at this, see there are more than 2 digits after the decimal and then drop them? (I don't want it to round the number)

    Any tips are appreciated!! :)
  124. Stacy
    Ok, disregard my previous post...I figured it out (DUH) * 100, then parseInt(), then / 100

    Guess I hadn't had enough coffee yet this morning! :)
  125. AuroraCF

    AuroraCF

    Hello,

    Does any body know how I can fix or code it correctly with incremental record to table?

    Here is my scenario:
    I read new record from tblRecNumber for new entry. Once the record insert to table I then update the tblRecNumber +1. This work ok with my other forms, for this flash form, its hold the tblRecNumber and use it over, and over again on second and third entry. Are there any way I can tell it to read new value from my tblRecNumber?
  126. Steve
    Have been trying to follow the real estate tutorial. Got it working with the sample database. Am now attempting to modify it to work with another test database with no success. My goal is to use the tutorial as a model to make my own custom database manager. The test database (MySQL 4.1) uses a Lot Number column as the Primary Key. This column is of type smallint(3) with integer values 1 to 500.

    If I try to create a text type search input box like below:
    searchArguments.Lot = search_Lot.text;

    <cfinput name="search_Lot" type="text" />

    I get an error message if the input box field is left blank. The error states that the value of the input passed to the query is not of type NUMERIC. Which means the entire search box will not work unless you enter a Lot number, which may or may not be known by the user of the search form.

    How do you set up the query so that it ignores the input of the Lot input box if it is NOT an INTEGER? The code below does not work:
    <cfargument name="Lot" required="false" type="numeric" default="0" hint="Lot number"/>

    <cfif len(arguments.Lot)>
          AND listing.Lot = <cfqueryparam value="#Lot#" cfsqltype="CF_SQL_INTEGER"/>
       </cfif>

    I tried changing the Lot column type in MySQL to VARCHAR(3), but when I do that the Lot numbers will not list in numerical order in a datagrid. Instead of 500 being the last record in ascending order, 99 becomes the last record since it is looking at the numbers as strings and not integers.

    I tried to create a cfinput search box for bedrooms (which is a smallint column) using the tutorial database, and that doesn't work either. Initially these queries would only error if the cfinput box was left blank (or if there was more than one cfinput box, if any of them were left blank), now even if I enter a valid integer into the box or boxes, it does not return a search result at all.. This is very frustrating! I'm trying to make a very simple search form that searches either by text input of Lot number or MLS number and nothing else, and cannot get it to work properly :(

    Also I don't understand how to write a query that may not have any inputs submitted to it. Say if there were only 2 cfinput text boxes, and the user didn't input anything and just hit the submit button. To make it so that no error would result. Any help would be appreciated!
  127. Daniel
    I cannot create a date object with input parameters in cfformitem type=”script”. The date object is always equal to the current system date. However, it works fine in cfsavecontent.

    The following codes are to make sure the selected date in the calendar is not the future date. Anyone has ideas? Thanks in advance.



    <cfsavecontent variable="CheckDate1">

       var todayDate = new Date(myForm.todayYear, myForm.todayMonth - 1, myForm.todayDate, 0, 0, 0, 0);
       var selectedDate = new Date(
                               myForm.select_date1.substr(6, 4),
                               myForm.select_date1.substr(0, 2) - 1,
                               myForm.select_date1.substr(3, 2),
                               0, 0, 0, 0
                            );
       alert("Today's Date in the cfsavecontent:\n" + todayDate + "\n\n" +
             "Seleced Date in the cfsavecontent:\n" + selectedDate);
             
       if (selectedDate > todayDate)
          alert("You cannot select a date greater than today's date");
       else
          alert("You are ok.");

    </cfsavecontent>


    <cfform name="myForm" format="Flash">
       
       <cfformitem type="script">
          function CheckDate2():Void
          {
             var todayDate = Date(myForm.todayYear, myForm.todayMonth - 1, myForm.todayDate, 0, 0, 0, 0);
             
             var selectedDate = Date(
                               myForm.select_date2.substr(6, 4),
                               myForm.select_date2.substr(0, 2) - 1,
                               myForm.select_date2.substr(3, 2),
                               0, 0, 0, 0
                            );
             
             alert("Today's Date in the cfformitem:\n" + todayDate + "\n\n" +
                   "Seleced Date in the cfformitem:\n" + selectedDate);

             if (selectedDate > todayDate)
                alert("You cannot select a date greater than today's date");
             else
                alert("You are ok.");
          }
       </cfformitem>

       <cfcalendar name="select_date1" height="150" width="310" onchange="#CheckDate1#">
       
       <cfcalendar name="select_date2" height="150" width="310" onchange="CheckDate2()">
       
       <cfinput type="text" name="todayYear"    value="#DateFormat(Now(), 'yyyy')#"    label="todayYear">
       <cfinput type="text" name="todayMonth"    value="#DateFormat(Now(), 'm')#"       label="todayMonth">
       <cfinput type="text" name="todayDate"    value="#DateFormat(Now(), 'd')#"       label="todayDate">
       
    </cfform>
  128. Chuck
    To add an 'incremented' Primary-Key, your fetch method must return the key, so that it gets added to the grid.

    Those that have this 'variable' doesn't exist in CFC or method/argument match. Variable names must match exactly, unlike passing variables from one CF function/method to another, the names of variables are only relevant to the inside function, but in remoting they must match letter for letter. If you pass method(edit_field.text), you must have inside the CFC, <cfargument name="edit_field.text" as the name of the argument. Try instead var MyRecordID:Number = edit_field.text, then call your method(MyRecordID), and derefrence it in the CFC <cfargument name="MyRecordID"...

    Instead, I have found that passing values as an object better/easier, and then using the ARGUMENTS scope to 'capture' the passed object and reference the variables in that matter handy.

    IE...
    var MyObj:Object = {};
    MyObj.MyRecordID = edit_field.text;
    formname.path.method(MyObj);

    inside CFC method()...
    use ARGUMENTS.MyRecordID...

    For testing purposes though, you need to have a <cfagrument name="args" type="struct" required="false">

    Then I have ...
    <cfset var copy = StructNew()>
    <cfif IsDefined("ARGUMENTS.args")>
    <cfset copy = ARGUMENTS.args>
    <cfelse>
    <cfset copy = ARGUMENTS>
    </cfif>

    And then use copy as the parameter to the component CFC's. I can then use a test.cfm to test a create,update,etc and pass a struct for it to work.

    This program is great for seeing what is going on between your Flash APP and the Server: http://www.kevinlangdon.com/serviceCapture/

    Hope this helps others, I've run into these myself.
  129. Lesley
    when my data displays in the cfgrid, either the data is blank (nothing when there should be something) or the word NULL is in the field.

    Does anyone know what causes this?
    Please help!
  130. Lesley
    Can anyone help with this? I am desperate!
    when my data displays in the cfgrid, either the data is blank (nothing when there should be something) or the word NULL is in the field.

    Does anyone know what causes this?
    Please help!
  131. Natalie

    Natalie

    How can I make price optional? If I don't enter anything for price & set required to false, I get "The argument PRICE passed to function create() is not of type numeric." I have the defaults set to 0 in the components as well.
  132. ash
    Hi iam trying to set up multiple selects inside a flash format. My code is working fine outside the flash form but not working inside.
    My cods is
    <cfselect name="state" label="STATE" multiple="yes" width="80">

    <option value>VIC</option>

    <option value>NSW</option>

    <option value>QLD</option>

    <option value>WA</option>

    <option value>ACT</option>

    <option value>SA</option>

    </cfselect>


    Please help
  133. Robert Hammond

    Robert Hammond

    hello Laura,
    I have been trying to deploy the real estate sample app on CF8 J2EE on tomcat 6.0. The GUI works fine, and remoting is also working fine but data is not able to be fetched from the database and data can not be inserted into the database either.
    I tried the dateResponder code and it worked fine, meaning that flashremoting is working well. Initially, i thought the problem was with tomcat so I tried CF8 J2EE on blazeDS but the problem was still the same. Then i tried to deploy Coldfusion 8 on Oracle's Standalone OC4J from Orion and the problem was still the same. I have built an application to deploy on the web using CF8 deployed as J2EE on Tomcat 6.0 so i please need your help on this. All I need to know is that, is this a known issue or is there a workaround to get the data to be fetched and inserted, updated and deleted from the database in the J2EE Configuration.

    Thanks for the Help.
  134. manu
    Hi,

    I'm facing an issue while accessing flsh forms on websphere.I have deployed coldfusion 8 developer edition on websphere[WAS] 6.1.All normal cfm pages are working fine but when trying to load any simple flash form ,i'm getting the following error "Error 500: flex.server.j2ee.cache.CacheFilter (initialization failure)".Any advice to resolve this issue would be greatly appreciated.