Our Blog

Real Estate Sample Application

We are happy to announce that the first part of a series of two articles, "The Real Estate Sample Application - Part 1: Building the Search Functionality", has been published at the Macromedia Developer Center. It's a walk through a Flash Forms sample application that uses Flash Remoting. You can view it running here. Before anyone asks, this is the almost-finished application, so it contains features not explained in the article and downloadable code. You will need to wait until the second part for that.

As always, you are welcomed to comment about it or ask any question here.

The Real Estate Sample Application – Part 1: Building the Search Functionality

Live example

Laura

Laura

110 Comments

  1. Michael E. Walker II
    Thanks for another great article. I have a large interest in Flash Forms and I'm glad this article like the many others you have suppplied are available for free to the community.
  2. Jason
    Bravo, you did it again!
    Got few questions here but I think I will wait till you post the part II.

    Thanks for the great post
  3. João Fernandes

    João Fernandes

    As usual, you did a great job.

    CFForms are great but you make them look even better.
  4. Holly
    Fantastic job. Can't wait for you guys to start publishing some Flex examples.
  5. JB
    Excellent work! Thanks for showing the real power behind CFForms and Flash. Examples like this show what the web really can be!
  6. Jason
    Laura,
    How is it possible to have a more dynamic amenities.

    For example if the amenities which are in a comma-delimited list instead of separate boolean field, how could we handle such list field in flash form?

    An example for this will be excellent!
  7. Damon Cooper
    Great stuff guys. The ColdFusion team loves seeing what you guys create with CF. Keep it up!

    Damon
  8. Neil Bailey

    Neil Bailey

    Laura & Nahuel,

    I have a question I hope you can help me out with. I have begun playing with drag-and-drop in cf flash form - and I have gotten it working, based HEAVILY on your mxna reader example. Thanks!

    However, I a trying to identify the SOURCE of the drag operation, and cannot for the life of me identify how to do it (can it be done within the doDragDropDG function???).

    I have read the documentatione extensively, and thought I was onto something with the dragSource object, but alas.......

    Can you (or anyone else) help me out??

    Thanks,

    nb
  9. David Brannan
    Another great example of what's possible with flash forms, remoting, and action script. Thank you for sharing your knowledge with this site!
  10. WayneG

    WayneG

    Well done! I have a very important question that I urgently need your help with. I have a editable grid with boolean check boxes. These can be checked or unchecked. The actionscrip loop pushes an array of all the columns via flash remoting to a cfc component. The argument in my function is set as an array, but I get an error when trying to loop over the array.

    I get it to work if I submit the whole flash form, so I know my cfc code works if I send it a struct. with the form array as per the var dump.

    What is the actionscript code to loop over a grid with say two columns only and have the array similiar to the form dump array?

    Please I really cant get this to work in weeks! I really would appreciate your help
  11. WayneG

    WayneG

    oophs sorry, The array would have say six columns, but i would only want 3 of the two columns.

    Thank so much for all the inspiration this blog has given us all...
  12. WayneG

    WayneG

    Dear Laura,

    Please find the code I have finally managed to get working

    function confirmClick():Void{
    var timesheetConfirmation:mx.controls.DataGrid = timesheetConfirmation;
    var args:Array = [];

    for(var i:Number = 0; i < timesheetConfirmation.length; i++){
    var item:Array = [];
                      item.intTimesheetID = timesheetConfirmation.dataProvider[i].intTimesheetID;
                      item.bitIsCaptured = timesheetConfirmation.dataProvider[i].bitIsCaptured;
                      item.bitIsConfirmed = timesheetConfirmation.dataProvider[i].bitIsConfirmed;
                      item.intLogUser = intLogUser.text;
                   args.push(item);
    }
             _global.confirmation(args);
    }

    the args then go to via facade.cfm to cfc which is then giving me the following error:

    You have attempted to dereference a scalar variable of type class java.util.ArrayList as a structure with members.

    I am looping the cffunction, with a cfargument set as type="array" name="args"

    This is where I need help please..

  13. Brook
    I'm sorry, I know this is totally unrelated. You two just seem like the best resource for flashforms out there. Is there any way you can tell me how the *&%$ to modify the file /cfusionMX/wwwroot/WEB-INF/cfform/user_classses/CFFormValidators.as

    And have it actually be used? I've made changes to the file, added traces, etc, but it doesn't make any difference?

    How the heck can I modif that file and have the changes work?

    Any Ideas?
  14. Luis Puesan
    This will help me at lot for a realestate site that I am developing. However, I have this error when I preview your 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. "
  15. Neil Bailey

    Neil Bailey

    Luis,

    You need to install the coldufion updater, and bring your server up to...I think its 7.01.

    This will solve your issue, and make your life a LOT easier when building dynamic cfforms in the future.

    You're looking for help in the right spot, however - these guys are mad scientists when it comes to this stuff, and I haven't seen a question posed yet that they can't answer...
  16. Jorge Tejada

    Jorge Tejada

    Hi, I want to know, how did you get to work Pollster 2.0 with ColdFusion MX 7. It worked for me on CFMX 6.1. But since I installed CFMX 7 it stopped working :(.
  17. thank you very much for the great tutorial, and I am looking forward to seeing the part II, thank you.
  18. Melissa

    Melissa

    How do you include a .as file? I have set up
    <cfformitem type="script">
    #include "a_flash_form.as"
    </cfformitem>.
    When I do this, my form does not load. Should all of my script be in the .as file? I am calling a function for onLoad to set up the remoting.
    Thanks.
  19. Luis Alvarez

    Luis Alvarez

    Beautiful example of Cforms in CF7. I've installed it out here. Any chance on getting a look at the code for detail section before part II comes out?
  20.  Ray Buechler

    Ray Buechler

    This excellent! Thank you for writting this article and sample app. Do you have any plans to port the Real Estate app to Flex 2? I think it would interesting to compare the CF7 flash forms version to a Flex version.
  21. markuz
    Hi.. great tutorial.. just wanted to ask.. how do i set focus in coldfusion forms? also, how do I set the defaultPushButton so a user would be able to submit a form when he hits enter on his keyboard instead of clicking a submit button? thanx alot.. great website!!!
  22. David
    Any chance you could score the completed source code for this? Thanks!
    david
    PS - Love the site!
  23. Dan
    Hi!

    I just need to clear something up in my head. Am I correct in saying that you don't need the following code in setUpRemoting()?

    var myService:mx.remoting.NetServiceProxy;

    It doesn't get called anywhere else. The service is in this tutorial is instantiated by:

    RealEstateAdmin.myGlobalObjects.listingsService = connection.getService( ... );

    Does creating a cfc with access="remote" extend NetServiceProxy?




  24. Steven Ross
    I know you guys are about to focus more on flex and not flash forms but, could you let us know if it is at all possible to have say a tree on the left that when you select an item in it loads a different interface on the right?

    Sort of the same way you built this app but imagine the bottom edit box changes based on your selection on the left. Is that possible in flash forms?
  25. Michael Steele

    Michael Steele

    Great article, one of the few I've seen that actually explain what developers are wanting to do with flash forms. please please please please hurry with part II
  26. Anthony

    Anthony

    all your postings have been great, and I see you are always evolving your remoting code. With this app you abstract out the setup remoting but only really call it once. It all works fine because your onResult function is designed for that call. What if I want the connection more reusable? I am using 1 cfc many times each method has it's own connection because the onResult function has to do something different each time. Can I tell inside the onResult function which method is returning the data? is there a way to do something like cfdump in actionscript on the result object? (or any actionscript object for that matter)

    Any insight would be great.
  27. Judah
    When do you anticipate the release of Part II. I have an app that is real similar and Part II code will help me solve my problems.
    Great article, Thanks!
  28. Laura
    Thank you everybody.
    The schedule for part 2 is end of November. So you'll have to wait a few more days :-)

    Ray,
    Yes, we have plans to make this app in Flex 2.


    Dan,

    > var myService:mx.remoting.NetServiceProxy;
    > It doesn't get called anywhere else

    You are right, that line of code is not necessary and it should be removed.


    Anthony,
    > What if I want the connection more reusable?
    > Can I tell inside the onResult function which method
    > is returning the data?

    You will see in part 2 that we do reuse the same connection for calls to other functions on the same component. Basically, you need to add other functions to the handler: responseHandler.myFunction_Result. You can read about that at http://www.asfusion.com/blog/entry/introduction-to-flash-remoting
  29. Steven Ross
    Is there any way to get coldfusion to generate a flashpaper document (using cfcontent) and have a flash form show it?
  30. Laura
    Steven,
    You can show a swf or a jpg in a cfform. That means you can then show charts or Flash Paper in a cfform.
    Check this post:
    http://ray.camdenfamily.com/index.cfm/2005/8/11/Flash-Forms-and-Flash-Paper
  31. John
    I've went ahead ahead and done the binding to the textfields once a place is selected. I've got a question on how you might pull a query off of each listing - say you had a table of house pictures, and when you clicked on a listing, how would you go about displaying that query for all the listing images. Basically - how would you do a query after selecting a listing and base it on that selection.
  32. Laura
    John,
    Since you brought the parent query with remoting, it makes sense to get that sub-query with remoting as well. It would be like the search, but you would call a different function, say getPictures(), and pass a parameter like the mls_id to get the list of pictures for that particular house.
  33. John
    Will try that today. One other thing - whenever I make a change to my gateway page - I have to restart my CF services on the server. Is there anyother way to flush the gateway connection after I make a change to it to get it to read the new changes?
  34. Luis Alvarez

    Luis Alvarez

    Dear Laura,
    I'm a newbie to remoting and cf7 forms.
    I've used your realestate app as a model for something I'm working on and it's been very helpful, thank you. Your article in CFDJ on data binding was great also. I'm ready for the next step. I understand Part 2 was supposed to be available at the end of Nov. Meanwhile I know how to bind the results from the grid to a detail form via bind=&quot;{}, but I don't understand how you can bind to a field that is not in the results grid. Is there a way of binding to the results of the query directly. I know this will be covered in part two, but can you give me an idea?

    On another note I heard you guys will be in Seatle speaking on the integration of cf7 &amp; flex, wish I could be there. Our company has just bought cf7 enterprise and is planning to use another copy for our production servers next year. Should we hold off and go with flex2, as we're considering RIAs for our apps, instead of investing in CF enterprise?
    Gracias,
    Luis
  35. Do you have any idea when the second part will be out?
  36. stephenwightman
    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 :
  37. Laura
    Luis,
    You still need CF for server-side development. It shouldn't be a choice between CF and Flex, they serve different purposes. If you are considering RIAs, I would strongly recommend to use Flex for the front-end and CF for the other stuff.

    stephen,
    You need the CF Updater.
  38. Dave
    I am receiving an JS error when opening the Realestate Apllication Part 1 or 2.

    Line: 61
    Char: 1
    Error: 'lc_id' is undefined
    Code: 0
    URL: http://192.168.200.162/realestate

    Hope you can tell me what I did wrong. Thanks
  39. Mike
    The example works great locally, but when i try to load it to my server i get his error when updating(deleting and adding works fine):

    Error executing database query
    Parameter ?_19 has no default value

    Any ideas
  40. Flash remoting is great, but whenever I change a gateway page I have to restart the CF applications server for the changes to work. Is there another way of getting the changes to take effect without restarting the server everytime?

    Thanks,
    Ashley
  41. Andreas Reichert
    Has anyone tested this Example on a multi-instance-server? I get an Error while trying it
    info [Flash Remoting MX]->java.io.FileNotFoundException
    at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:79)
    at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
    at jrun.servlet.JRunRequestDispatcher.invokeNext(JRunRequestDispatcher.java:534)
    at jrun.servlet.JRunNamedDispatcher.include(JRunNamedDispatcher.java:91)
    at flashgateway.adapter.java.ServletAdapter.invokeFunction(ServletAdapter.java:79)
    at flashgateway.filter.AdapterFilter.invoke(AdapterFilter.java:266)
    at flashgateway.filter.SecurityFilter.invoke(SecurityFilter.java:85)
    at flashgateway.filter.LicenseFilter.invoke(LicenseFilter.java:58)
    at flashgateway.filter.ErrorFilter.invoke(ErrorFilter.java:44)
    at flashgateway.filter.LogFilter.invoke(LogFilter.java:43)
    at flashgateway.filter.BatchProcessFilter.invoke(BatchProcessFilter.java:63)
    at flashgateway.filter.DebugFilter.invoke(DebugFilter.java:38)
    at flashgateway.filter.SerializationFilter.invoke(SerializationFilter.java:59)
    at flashgateway.Gateway.invoke(Gateway.java:194)
    at flashgateway.controller.GatewayServlet.service(GatewayServlet.java:56)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
    at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
    at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:259)
    at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:541)
    at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:204)
    at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
    at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
    and form is returning something like "service not found".
    Does anyone know, what's wrong with it? My first thought was, that the component is not found, but it's hard to debug without any realizable error-Output
  42. David
    Andreas,
    I had the same problem for a while. In my case, i had the issue where my gateway or dao objects were not being created, so it generated the same error because it couldn't find anything in memory. You most likely have to change your application.cfc's component path variable to match what your current folder system is. Hope this helps!
    David
  43. David
    Ashley,
    An easy way to flush your application is to use applicationtimeout. I use mine like so:
          this.applicationTimeout=CreateTimeSpan(0,24,0,0);

    If i'm testing locally i'd probably change it to
          this.applicationTimeout=CreateTimeSpan(0,0,0,1);
    that way the application will timeout after a second , and restart when i close my browser.
    Hope this helps!
    David
  44. Andreas Reichert

    Andreas Reichert

    David,

    no change at all - in my opinion it is a configuration problem with the flashgateway. But i can not find any documentation about it.
  45. Andreas Reichert

    Andreas Reichert

    Ok, i reinstalled Jrun repeatedly - and suddently it worked. I don't know what the Problem was, but now it's working
  46. Josh Swenson
    I was wondering if anyone else has had trouble with <cfformitem> and the type="script" attribute. I've been going through the realestate example and I always get an error saying that indeed the type="" script attribute was no good. I can circumvent the error if I make a couple of changes like <cfformitem type="html"><script>....</script></cfformitem>. My flash form does appear but it is completely blank and empty and I was wondering if anyone had any ideas. Thanks

    Joshua Swenson
  47. Neil
    There was a coldfusion updater - came out a WHILE back - that added the "script" option to the cfFormItem types.

    I have no idea how you're creating dynamic forms w/out it...
  48. Sandra

    Hi,

    Is there any way to populate the grid using flash remoting w/o using the search function, or w/o having the user to press a button to populate the grid?

    I just want the users to select an item in the grid and then populate the forms so that they can edit, add and delete records from the DB.

    Thanks.
  49. Laura
    Sandra,
    Check this post:
    http://www.asfusion.com/blog/entry/knowing-when-the-cfform-data-arrives

    However, there is no need to load data manually with remoting if you just want to have it there to edit.
    The search was just a simple example to show how remoting works.
  50. Sandra

    Sandra

    Thank you so much Laura =) I appreciate your help.

    Now I'm running into another problem when deleting a record, I'm getting this error message "Element ROLE_ID is undefined in arguments".... in the tutorial the function delete only requires the id of the record to remove, but my program requires two ids to delete the record.

    Heres is my code:

    This is from the component that handles the delete:

    <cffunction name="remove" output="false" hint="Deletes a property listing" access="public" returntype="string">
       <cfargument name="user_ID" required="false" type="string" hint="user_ID"/>
       <cfargument name="role_ID" required="false" type="string" hint="role_ID"/>
       <cfargument name="name" required="false" type="string" hint="ID"/>
       
          <cfset var deleteListingQuery = "" />

          <cfquery name="deleteListingQuery" datasource="hs_sql2">
           DELETE FROM dbo.Employee_Roles
    WHERE dbo.Employee_Roles.user_ID = <cfqueryparam value="#arguments.user_ID#"/>
    AND dbo.Employee_Roles.role_ID= <cfqueryparam value="#arguments.role_ID#"/>
          </cfquery>      

          <cfreturn arguments.role_ID />
    </cffunction>   


    and this is from the flash remoting service component:

    <cffunction name="remove" access="remote" returntype="struct" output="false" description="Removes a listing">
       <cfargument name="user_ID" required="false" type="string" hint="user_ID"/>
       <cfargument name="role_ID" required="false" type="string" hint="role_ID"/>
       <cfargument name="name" required="false" type="string" hint="ID"/>
       
    <cfset var remoteLog = createObject("component", "sandra.er.flashRemoting")/>
       
    <cfset var result = structnew()/>
       
    <cfset remoteLog.remove(argumentCollection=arguments)/>
       
       <cfset result["status"] = javacast("boolean", true)/>
       <cfreturn result/>
          
    </cffunction>

    and this is my response handler:

    responseHandler.remove_Result = function( results: Object ):Void {               
             
             if (results.status){
                username.removeItemAt(_root.findItem(username,'user_ID',results.item.user_ID));
                username.removeItemAt(_root.findItem(username,'role_ID',results.item.role_ID));
                
                _root.setMode('add');
                
                alert("Record has been removed");
             }
             else {
             
             alert ("Record could not be removed");
             
             mx.managers.CursorManager.removeBusyCursor();
             }
                
          }

    what am I doing wrong?? =((

    I'd really appreciate your help.
  51. Laura
    Sandra,
    You are not showing the important part, where you call the remoting function :)
    The error is telling you you are not sending all the necessary parameters. When you call your service now it looks something like this:
    myService.remove(user_ID);
    you need to add the role to the function call:
    myService.remove(user_ID, role_ID);

    Also, you don't need to do this twice:
    username.removeItemAt(_root.findItem(username,'user_ID',results.item.user_ID));

    but you will have to modify the findItem function to be able to find items based on 2 ids, not only 1. To simplify things you could replace it with
    username.removeItemAt(username.selectedIndex); (it may not always work if the user changes selection before the remoting call gets back)
  52. Steve Walker
    Laura,

    This is going to seem like a silly question, but is there a way to pull back the number of records returned once the search is completed (RecordCount)?
  53. Laura
    Steve,
    When the results are returned you can check for results.length (&quot;results&quot; or the name of your parameter)
  54. Steve Walker
    Laura,
    Thank you for the quick reply. This is where my inexperience shows. Can I show it to the user each time they run a search? I am not sure how to reference it.
  55. Steve Walker
    I would like to to create a record navigation button that automatically goes through the grid and populates all the bound fields. Doable?
  56. Steve Walker
    Laura,

    I found the answer to the previous question concerning displaying the record count. If anyone else is curious, the way to dynamically disply the number of records found in a grid similar to this app the syntax is:

    _root.MyTextBox.text = results.items.length;

    I placed it inside the remoting function and it works flawlessly. Thanks to Todd Sharp's database app (cfsilent.com)
  57. Steve Walker
    I know you guys are in the middle of migrating to a new blog engine, so I hope this gets to you. I have a search interface like the Real Estate example and I want to be able to pass the search parameters, used to populate the grid, to a cfreport that creates an excel file. I was hoping to use something similar to the submitSearch() function, is it possible?

    I can't wait to see your new blog engine.
  58. Laura
    Steve,
    Regarding your first question, you could do that by changing the selected item like this (you should check for bounds)
    myGrid.selectedIndex++;

    Regarding your second question, of course it is possible. You can do whatever you want in the server, it doesn't have to be a query that you return. The client side does not have to change if you pass the same parameters. Now, what you do what with the excel file is another story.
  59. Xerrano
    Hi great app!!!

    I like to know if someone can explain why I can't make work this line of code in my application.cfc...

    <cfset application.listingGateway = createObject("component","cfc.ListingGateway").init(application.dsn_properties) />

    URL to CFC:
    /cfc/ListingGateway.cfc

    I try to use it like this:
    <cfreturn application.listingGateway.search(argumentCollection=arguments) />

    This is the error I get:
    Error: Element LISTINGGATEWAY is undefined in a Java object of type class [Ljava.lang.String; reference as...

    BUT WHEN I CALL THE ListingGateway.cfc directly without using the ListingServices.cfc component works ok.

    Any ideas... Looks like the createObject is not working, correct?


    Thanks.


    Xerrano
  60. Laura
    Xerrano,
    Have you tried refreshing the app (changing the name of the application, restarting cf, etc)? Why don't you make a dump of the application <cfdump var="#application#"> in a regular cfm file to see if the component is there?
  61. Jimmy
    Hello,

    First I want to say this an awesome application you created. I'm kinda stuck on a problem. I took your example and was able to create something similar to your. I'm at the point where I have 2 date field, and a cfselect.
    The user select a date range and then from the select they have 2 option Male/Female. When the user clicks the search button it SHOULD go and query my DB and display all the birthday in the Date Range and the gender selected in my CFGRID. The problem is I don't know where to start with this. Do I create a function that accepts the 3 fields and return a result stored in CFGRID using an OnClick()? I noticed you're using CFC on your example, I'm still learning flash remoting and all, and got lost on how you did it on your example. Can some please help me out on this?

    Thanks,
    Jimmy
  62. Laura
    Jimmy,
    If you ask me where to start, I would tell you to read the article and try the code we show as it explains how to do the search step by step, what you need on the form, what you need on the server, etc. You can also read part 2 if you need to update the data in the datagrid.
  63. Paul
    This example application is awesome! I have started making an example application for work, and for some reason in my version of the program, when I hit search, it does everthing right and the grid gets the right data, but all of my form variables in the search pane reset, any ideas?
  64. Paul
    Found it, there is a resetform() in the actionscript for the setmode()

    Thanks
  65. Tony Eckert

    Tony Eckert

    I love this app.

    Something I am curious though is if it's possible to search for just part of MLS ID and then the grid would display all entries which contain that string in it. Example, if you cannot remember the full MLS ID number, but know that it ends with a 78, I would like to type in 78 into the search and have all entries with the string 78 in them to display in the grid. I'm sure there is a way, but I'm pretty new at remote forms and haven't had any luck on google for this answer. Any help would be appreciated.
  66. Laura
    Tony,
    That would need a simple change in the query. Instead of doing:
    listing.mls_id = <cfqueryparam value="#mls_id#" cfsqltype="CF_SQL_VARCHAR"/>
    You would do:
    listing.mls_id LIKE <cfqueryparam value="%#mls_id#%" cfsqltype="CF_SQL_VARCHAR"/>
  67. Tony Eckert

    Tony Eckert

    That worked just how i wanted it! Thanks so much Laura!
  68. Tony Eckert

    Tony Eckert

    I noticed that you cannot edit the MLS ID values in this app. Digging into the code, it looks like all the updates are done based on WHERE MLS_ID = #arguments.MLS_ID#. But if you want to change the MLS_ID on the form, you would lose the original value and the update would break.

    I have taken things a step further by adding an additional column in the database, ItemID, which acts as a unique identifier for each MLS_ID entry. So, if you wish to update the MLS_ID, you simply point the update to WHERE ItemID = #arguments.ItemID#.

    I have ItemID set up as an AutoNumber in the DB, using increment numbers, so every new entry I make the ItemID number increases by 1. I've run into one small problem though. Ever since I made the ItemID an autonumber with increment, I get a blank entry in the CFGrid after adding a new item, rather than seeing the item I just added. If I click the "search" button on the search panel, my entry appears. So, is there something about autonumbers that doesn't get updated imediately upon submitting a new entry?
  69. Laura
    Tony,
    The problem is not the autonumber per se, it would be the same if you used any other string/number, etc.
    The problem is that since you are creating a new id, you must return that id to the grid. See the structure that we return when creating or updating a result. In that structure, you must include the id you created, with the key name being the same as the column name in your grid.
    I am not sure if you also see the other columns as blank, if so, then check that the structure keys are the same as your column names.
  70. Tony Eckert

    Tony Eckert

    Ah, good points all around. So now my question is how do I get the return results function to recognize that the new ItemID is not stored in arguments.ItemID?

    The DAO contains the create function as you know. Inside this I am setting the returnObj["ItemID"] = arguments.ItemID -- Of course, arguments.ItemID should be empty because we haven't entered input for it, nor do we want to because it's an incremented autonumber. The result of this will return a blank line in the cfgrid since the entity is null/empty.

    So, what can I do to set the returnObj ItemID to the new ItemID? This is where my problem sleeps.
  71. Tony Eckert

    Tony Eckert

    Laura,
    I found a work-around.
    For the fetch function:
    <cfset var getlistingQuery = ""/>
    <cfset var data = structnew() />
    <cfquery datasource="blahblahblah" name="lastID">
       SELECT MAX(ItemID) AS cID
       FROM table_name
    </cfquery>
    <cfquery name="getlistingQuery" datasource="#variables.dsn#">
       SELECT *
    FROM table_name
    WHERE ItemID =
    <cfqueryparam value="#lastID.cID#" cfsqltype="cf_sql_integer" maxlength="10"/>
    </cfquery>


    and for the create function:
    <cfquery datasource="blahblahblah" name="countemID">
          SELECT MAX(ItemID) AS cID
          FROM table_name
       </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"] = "Item has been inserted"/>
       <cfoutput>
    <cfset returnObj["ItemID"] = #countemID.cID#>
       </cfoutput>
    </cfif>
    <cfreturn returnObj/>


    Only problem is I had to create another fetch command to take care of the update function.

    If you've got a better way of doing things, please let me know. thanks!
  72. Laura
    Tony,
    Your code is fine. You just don't need to change the fetch function. I suppose your fetch function takes the ItemID as an argument. Since now your create function returns the newly created id, you can use the same fetch function fetch(result.ItemID)
  73. herbert

    herbert

    hi cfform experts,
    i want to adopt your great realesate sample and have some "beginner" questions:
    1)
    how can i show the grid with some initial settings from the search-form? i.e the status sold is selected

    2)
    in your example - if i make some selections (active, footage ..) the search options switch back to the initial form values after a search, except the pulldown values.

    is it possible to keep the selected search options?
    and how?


    kind regards
    herbert
  74. Xerrano

    Xerrano

    Hi Laura..

    Is there a chance you can help me to achieve this:
    I like to use more than one table in my database to include real estate agencies and relate any property to any agency using agency_ID.

    this is my listingGateway cfquery right now, but is not working.

    <cfset var listingQuery = "" />

    <cfquery name="listingQuery" datasource="#application.dsn_properties#">
       SELECT mlvnet_properties.*
       FROM mlvnet_properties
       WHERE mlvnet_properties.property_price >= <cfqueryparam value="#arguments.priceFrom#" cfsqltype="CF_SQL_MONEY"/>

    <cfif arguments.priceTo GT 0>
       AND mlvnet_properties.property_price <= <cfqueryparam value="#arguments.priceTo#" cfsqltype="CF_SQL_MONEY"/>
    </cfif>


    -- some code removed --


    <cfif len(arguments.mls_id)>
       AND mlvnet_properties.property_ID = <cfqueryparam value="#mls_id#" cfsqltype="CF_SQL_VARCHAR"/>
    </cfif>

    <cfif len(arguments.keywords)>
       AND mlvnet_properties.property_keywords = <cfqueryparam value="#keywords#" cfsqltype="CF_SQL_VARCHAR"/>
    </cfif>

    <cfif len(arguments.agency)>
    UNION
       SELECT mlvnet_agencies.*
       FROM mlvnet_agencies
       WHERE mlvnet_properties.agency_ID = mlvnet_agencies.agency_ID AND mlvnet_agencies.agency_name = <cfqueryparam value="#agency#" cfsqltype="CF_SQL_VARCHAR"/>
    </cfif>

    <cfif len(arguments.locations)>
    UNION
       SELECT mlvnet_locations.*
       FROM mlvnet_locations
       WHERE mlvnet_properties.location_ID = mlvnet_locations.location_ID AND mlvnet_locations.location_name = <cfqueryparam value="#locations#" cfsqltype="CF_SQL_VARCHAR"/>
    </cfif>

    ORDER BY mlvnet_properties.property_price DESC


    Any ideas?


    Thanks

    Felipe Serrano
  75. xerrano
    ok, I might not be so clear on my post.

    Can anyone show me how to query from more than just one table?

    I tryed to do it, and this is what happen: I set up only two realestate-properties in my porperties table using agency_ID's 1 and 2 and about 40 property offices. When I make a search with no options selected every property appeaer 40 times. But When I try a new search mixing some options, either the first or the second property appear (the way it should)...


    Any ideas?


    Thanks
  76. Lesley
    How do you have search fields that can search for text in either upper case or lower case?
  77. Laura
    herbert,
    1) The search panel only contain simple controls. You can set any default you want depending of what type of control they are. For example, if you want to have a default for a dropdown, use the "selected" attribute, for a text input, use its "value" attribute, etc). See the CF docs for the other controls.

    2) That happens because we call "resetForm()" when the search results are received. We did that to avoid other issues and to make things simpler. If you remove that, the search criteria will stay.

    Felipe,
    You obvioulsy have a SQL problem, which I can't resolve for you. I think you should try your queries in a simple cfm file until you get the expected resulst. By the way, you probably want to use JOIN instead of UNION, but I don't really know what you want to do or what your db schema looks like. (Check an SQL book to see how to make a query that involves more than one table)

    Lesley,
    Like Felipe, that is a SQL question (at least in the context of the article). Depending on your db, searches are either case sensitive or not. Check your db's syntax and defaults.
  78. Paul
    In the example, why does the datechooser selectedDate for the date listed not change when the selectedItem in the listingGrid change. the text value of the datefield changes, but the datechooser is stuck on the last date that was picked. Is their a way to bind the date chooser as well?
  79. Justin

    Justin

    Just curious how many development hours it took you all to develop the real estate app using Flash forms?
  80. 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
  81. xerrano
    Hi there again...
    Has anyone apply a function to upload images?
    my app would have an option to upload up to 10 pictures, does anyone may help out on how to embed the upload image function?

    Thanks
  82. Lesley

    Lesley

    I created a coldfusion MX7 flash form with a grid on my computer. When our IT department loaded it to the MX7 server it doesn't show any of the flash components. He upgraded the server to 7.2 but all we get is a blank page. Are there any suggestions on what the fix it? Please advise us!
  83. Laura
    Lesley,
    Does your server have the CFIDE directory there or as a virtual directory?
  84. Lesley
    I think IT mentioned the directory, but I don't have access to that server so I can't see it.
  85. Lesley

    Lesley

    I am still having trouble trying to figure out what is wrong with my application. It works fine on my personal computer, but when IT loaded it to the Coldfusion server all I get is a blank page. They turned on debugging, but the only thing it showed that it took over 250 ms to run. Other than that, it didn't say much.

    What else should I look for? I really need some help since out IT department is not allowed to help me.

    Does anyone else have any suggestions?

    Thanks in advance
    Lesley Schulz
  86. Laura
    Lesley,
    Try copying the entire CFIDE folder (from your local copy) to the root of your domain. You can omit the administrator folder, you don't need that.
  87. Lesley
    HELP! I'm drowning here! I am still having trouble getting my application to run on the server. This is all I get from the debugging window.

    Execution Times

    Total Time Avg. Time Count Template

    11031 ms 11031 ms 1 D:\CFusionMX\wwwroot\MHC\index.cfm

    3047 ms 3047 ms 1 CFC[ E:\inetpub\wwwroot\MHC\components\search.cfc | list() ] from E:\inetpub\wwwroot\MHC\components\search.cfc

    0 ms 0 ms 1 D:\CFusionMX\wwwroot\MHC\Application.cfm

    203 ms STARTUP, PARSING, COMPILING, LOADING, & SHUTDOWN

    11234 ms TOTAL EXECUTION TIME
    red = over 250 ms average execution time

    I copied the CFIDE folder to the server and removed the administrator folder. Any other suggestions?
  88. Lesley

    Lesley

    The CFIDE folder is in the root, but it still isn't displaying anything. In the bottom left of the page it has an exclaimation point and when I click on it it just says "Line 84 object unexpected". I have checked the code and I don't see anything wrong and it works on my computer just not the server. Any suggestions?

    Please help! I am very desperate!
  89. Michael

    Michael

    Hi Laura,

    This is a great application and I've been working to try to modify it to work for an application I'm building.

    The search works wonderfully and I've finally got the updates to work, but I'm having problems with the grid updating when the I submit the update.

    When I click submit, the grid goes blank and there is no alert message that the item was updated. I have to run the search again to populate the grid, which shows the updated item.

    My fuctions are basically the same code as yours except for name changes.

    Here is the code that handles the update respone:
    <!--- handle update response --->
    responseHandler.update_Result = function( results: Object ):Void {
    var item:Object = results.item;
    //find the item's index
    var index:Number = _root.findItem(ActionGrid,'ACT_NUM',item.ACT_NUM);

    if (results.status && index >= 0){
    ActionGrid.replaceItemAt(index,item);
    }

    mx.managers.CursorManager.removeBusyCursor();

    <!--- show a message --->
       alert(results.message);   
    }


    Helper Function to find item in datagrid:
    <!--- helper function to find an item in a datagrid --->
    public function findItem(grid:mx.controls.DataGrid, columnToSearch:String, id:String):Number {

          for (var i = 0; i < grid.dataProvider.length; i++){
             if (grid.getItemAt(i)[columnToSearch] == id){
                return i;
             }
          }
          <!--- not found --->
          return -1;
       }


    My fetch function is written the same as yours other than the names of the fields and such.

    Is there something I'm missing or something somewhere else in the code I need to look at?

    Any help you could provide would be wonderful.

    Thanks again so much for this example. Once I get this working this will help speed up our loging system greatly.
  90. Felipe Serrano
    HELP!

    Now the search results loads into the CFGRID, is there a way to take those results outside the cfform below into a <divs> formated CFLOOP instead the CFGRID, Keeping the the no-refresh feature?


    THANKS
  91. Mike Collins

    Mike Collins

    Andreas,

    Regarding
    [Flash Remoting MX]->java.io.FileNotFoundException

    I have found new servers added with Enterprise Manager will find the flashgateway.ear while the cfusion server does not deploy it. So simply renaming the flashgateway.ear will get around this issue.

    Thanks,
    Mike
  92. Chris Dauw

    Chris Dauw

    Hello -

    I have a quick question that I was wondering if someone could help me with.

    Lets say you wanted to add an indicator to the edit form that flags records where the "Date Listed" was older than 90 days. How would you go about doing that?

    I imagine you would have to add a function to the listingGridChanged() code that would do a date comparison between the value of the date listed field for the row selected and the current date. The only problem is I havent been able to find any documentation detailing how to do this in Action Script that works within CF. Any ideas?

    Thanks in advance,

    Chris
  93. Ram
    Hello
    I am running into the same problem that was posted here, but unfortunately have not been able to resolve. I am getting the error "Element LISTINGGATEWAY is undefined in Java Object of type class [LJava.lang.String] referenced as etc.."

    I tried changing the Application name, but that doesnt help.

    Urgently needs tips on how to resolve this...
    Thanks,
    -Ram
  94. Howard

    Howard

    I want to use flash remoting , but what are the steps to integrate flash with coldfusion. I have the application built, but I tried to install the components for flash remoting on the Adobe website, but I got an error of ISSCRIPT.MSI is not running or unavailable. Now I installed the ISSCRIPT.MSI , which was a requirement to get the flash remoting components to install. Please anyone, tell me if there is a possible solution to the problem I am having. Can anyone outline the steps to integrate flash remoting to coldfusion? Thanks
  95. gaurav khanna

    gaurav khanna

    Flash form issues
    I have copied CFIDE and tried creating virtual directory but flash forms still have issues.
    Do flash forms only work in the default website??
  96. fred
    My cfform type="flash" is failing. The only way to get it restarted is to restart the coldfusion server. This is not acceptable. Then it goes down again and I need to restart again. Thanks.
  97. 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.
  98. Casey McLaughlin

    Casey McLaughlin

    I've adapted the application and I the responsehandler.onResult function is getting a result. I can set an alert to show the length of the listinggrid which shows the correct 3091 records queried from the database. My cfgrid looks like its getting the data as a vertical scroll bar appears, but no actual data is showing up.
    I've kept the code as close to the example as possible. Could someone throw me a bone on a solution here?
    I've tried this on both CF 7.01 and 8.01 with the same results.

    <!--- handle search by default onResult function --->
    responseHandler.onResult = function( results: Object ):Void
    {
    listingGrid.dataProvider = results;
    listingGrid.selectedIndex = undefined;
    alert(listingGrid.length);
    mx.managers.CursorManager.removeBusyCursor();
    }


    <cfgrid name="listingGrid" rowheaders="false">
    <cfgridcolumn name="Sample" header="Sample"/>
    </cfgrid>
  99. Laura
    Casey,
    That is usually a problem of case sensitivity. Make sure you define your columns with the right case.
  100. Casey McLaughlin

    Casey McLaughlin

    Wow, I did not realize CF was so picky about cases for field names. I'm glad it was a simple problem. I've used your real estate application example as a tutorial and greatly appreciated your writing and the comments here.

    THANKS
  101. ravi
    Laura, I was able to get the results. The column name was case sensitive and change to upper case and it worked fine. Whew!
  102. ravi
    Hi Laura,
    I have the same issue as Michael. I click submit and the top row of the grid goes blank. It doesn't show the newly inserted record. But, when I click search it brings the newly inserted record. Could you please help where is the mistake? TX.
  103. Lois
    I have a ery different issue - I can't seem to dynamically name a cfgrid. I know that you can't have 2 grids with the same name, and the grids are within a loop so I need to dynamically name them based on the time they ar through the loop. My code is below, and I'd be very grateful for any insight anyone can provide:


    <cfset GrdHeight = (qryLOBContact.recordcount * 20) + 20 >
                   <cfset FormName = "#LOB_ID#ContactSet"><cfdump var="#FormName#">
                <span class="normal"><Cfoutput>#qryLOBContact.LOB_Name#</cfoutput></span><br />
                <cfform format="flash" action="?Act=upd" name="Contactlist" skin="haloBlue" accessible="true" height="#FrmHeight#" width="935">
                   <cfgrid name="#FormName#" format="flash" query="qryLOBContact" height="#GrdHeight#" colheaderbold="true" colheadertextcolor="##067ab4" >