Oct
31

ColdFusion Flash Forms Macromedia Developer Center article

104 comments Posted by: Laura

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

Category: CFForm | ColdFusion | Flash Remoting |

104 Comments so far

Write yours
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.
Jason
2. Jason wrote on October 31, 2005 at 11:47 PM
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
Michael
Just 1 word, WOW!
You amaze us everytime with the flashforms!
João Fernandes
4. João Fernandes wrote on November 01, 2005 at 4:25 AM
As usual, you did a great job.

CFForms are great but you make them look even better.
George
5. George wrote on November 01, 2005 at 5:52 AM
Yeah, waiting for the second part.
Holly
6. Holly wrote on November 01, 2005 at 9:44 AM
Fantastic job. Can't wait for you guys to start publishing some Flex examples.
JB
Excellent work! Thanks for showing the real power behind CFForms and Flash. Examples like this show what the web really can be!
Jason
8. Jason wrote on November 01, 2005 at 10:33 AM
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!
Damon Cooper
Great stuff guys. The ColdFusion team loves seeing what you guys create with CF. Keep it up!

Damon
Phil
Great work again and I Can't wait for part II!!
Neil Bailey
11. Neil Bailey wrote on November 01, 2005 at 12:52 PM
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
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!
WayneG
13. WayneG wrote on November 01, 2005 at 9:45 PM
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
WayneG
14. WayneG wrote on November 01, 2005 at 9:48 PM
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...
WayneG
15. WayneG wrote on November 02, 2005 at 1:07 AM
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..

Brook
16. Brook wrote on November 02, 2005 at 6:01 PM
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?
Kunal Anand
This has got to be the neatest flash form application I have seen. Absolutely stellar.
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. "
Neil Bailey
19. Neil Bailey wrote on November 05, 2005 at 3:33 PM
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...
Jorge Tejada
20. Jorge Tejada wrote on November 06, 2005 at 3:00 PM
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 :(.
ez
thank you very much for the great tutorial, and I am looking forward to seeing the part II, thank you.
Melissa
22. Melissa wrote on November 07, 2005 at 12:49 PM
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.
Paul
23. Paul wrote on November 10, 2005 at 2:09 AM
Great tutorial. When can we see part 2?
Josh Rodgers
24. Josh Rodgers wrote on November 10, 2005 at 10:32 AM
Yes when is Part 2 coming out ?
Luis Alvarez
25. Luis Alvarez wrote on November 10, 2005 at 2:02 PM
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?
 Ray Buechler
26. Ray Buechler wrote on November 11, 2005 at 5:33 AM
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.
markuz
27. markuz wrote on November 15, 2005 at 11:03 AM
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!!!
David
28. David wrote on November 16, 2005 at 11:19 PM
Any chance you could score the completed source code for this? Thanks!
david
PS - Love the site!
Dan
29. Dan wrote on November 17, 2005 at 5:01 AM
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?




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?
Michael Steele
31. Michael Steele wrote on November 17, 2005 at 2:29 PM
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
Anthony
32. Anthony wrote on November 18, 2005 at 9:40 AM
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.
Judah
33. Judah wrote on November 18, 2005 at 12:27 PM
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!
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
Steven Ross
Is there any way to get coldfusion to generate a flashpaper document (using cfcontent) and have a flash form show it?
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
John
37. John wrote on November 28, 2005 at 11:28 AM
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.
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.
John
39. John wrote on November 30, 2005 at 5:24 AM
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?
Luis Alvarez
40. Luis Alvarez wrote on November 30, 2005 at 6:40 AM
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
D
Do you have any idea when the second part will be out?
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 :
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.
Dave
44. Dave wrote on January 09, 2006 at 3:43 PM
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
Mike
45. Mike wrote on January 17, 2006 at 7:34 PM
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
Ashley
46. Ashley wrote on January 18, 2006 at 7:38 AM
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
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
David
48. David wrote on February 09, 2006 at 8:43 AM
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
David
49. David wrote on February 09, 2006 at 8:46 AM
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
Andreas Reichert
50. Andreas Reichert wrote on February 10, 2006 at 2:52 AM
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.
Andreas Reichert
51. Andreas Reichert wrote on February 13, 2006 at 2:47 AM
Ok, i reinstalled Jrun repeatedly - and suddently it worked. I don't know what the Problem was, but now it's working
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
Neil
53. Neil wrote on March 15, 2006 at 10:17 AM
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...
Sandra
54. Sandra wrote on March 29, 2006 at 6:17 AM

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.
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.
Sandra
56. Sandra wrote on April 07, 2006 at 9:21 AM
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.
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)
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)?
Laura
Steve,
When the results are returned you can check for results.length (&quot;results&quot; or the name of your parameter)
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.
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?
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)
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.
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.
Steve Walker
Laura,

Thank you for the answer. It never occurred to me to simply put double plus signs.
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
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?
Jimmy
68. Jimmy wrote on May 31, 2006 at 12:19 PM
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
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.
Paul
70. Paul wrote on June 11, 2006 at 6:46 PM
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?
Paul
71. Paul wrote on June 12, 2006 at 8:23 AM
Found it, there is a resetform() in the actionscript for the setmode()

Thanks
Tony Eckert
72. Tony Eckert wrote on June 29, 2006 at 5:47 AM
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.
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"/>
Tony Eckert
74. Tony Eckert wrote on July 05, 2006 at 6:51 AM
That worked just how i wanted it! Thanks so much Laura!
Tony Eckert
75. Tony Eckert wrote on August 01, 2006 at 1:32 PM
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?
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.
Tony Eckert
77. Tony Eckert wrote on August 03, 2006 at 6:50 AM
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.
Tony Eckert
78. Tony Eckert wrote on August 03, 2006 at 8:30 AM
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!
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)
herbert
80. herbert wrote on September 07, 2006 at 6:17 AM
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
Xerrano
81. Xerrano wrote on September 11, 2006 at 2:55 PM
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
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
Lesley
83. Lesley wrote on September 20, 2006 at 2:02 PM
How do you have search fields that can search for text in either upper case or lower case?
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.
Paul
85. Paul wrote on October 17, 2006 at 9:05 AM
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?
Justin
86. Justin wrote on November 09, 2006 at 7:23 PM
Just curious how many development hours it took you all to develop the real estate app using Flash forms?
xavy
87. xavy wrote on November 18, 2006 at 11:25 PM
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
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
Lesley
89. Lesley wrote on January 09, 2007 at 10:57 AM
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!
Laura
Lesley,
Does your server have the CFIDE directory there or as a virtual directory?
Lesley
91. Lesley wrote on January 11, 2007 at 10:49 AM
I think IT mentioned the directory, but I don't have access to that server so I can't see it.
Lesley
92. Lesley wrote on February 06, 2007 at 3:15 PM
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
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.
Lesley
94. Lesley wrote on February 21, 2007 at 3:12 PM
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?
Lesley
95. Lesley wrote on March 05, 2007 at 2:07 PM
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!
Michael
96. Michael wrote on July 12, 2007 at 9:20 AM
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.
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
Mike Collins
98. Mike Collins wrote on August 21, 2007 at 2:43 PM
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
Chris Dauw
99. Chris Dauw wrote on October 04, 2007 at 5:30 PM
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
Ram
100. Ram wrote on January 21, 2008 at 1:44 AM
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
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
gaurav khanna
102. gaurav khanna wrote on March 25, 2008 at 1:06 PM
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??