Generate ColdFusion Code Powered by Flex
All you should need to do is:
1) Download the files and place them in a folder on your web root (if the folder is not named cfcgenerator, you will need a mapping with that name);
2) Open Application.cfm and change the value of adminPass to your ColdFusion Administrator password.
That's it. The ColdFusion components are kept in application scope, so if you make any changes after you load the app, just append ?reload=true to the URL. Remember that the Flex/ColdFusion communication requires ColdFusion 7.0.2. Also remember this is alpha software :)
Using the Generator and New Features
Using the generator should be pretty intuitive. When the app loads it will populate a list of all the supported DSNs (currently MSSQL, Mysql - 5.0 only I think as it was never tested on 4.1 - and Oracle). It will then load a list of tables within the preselected dsn. Lastly, it loads the included templates (currently the default, prototype - just a copy of default intended to be customized, and Transfer). This leads me to one of the main new features, you can switch templates on the fly rather than have them tied to a dsn as before.
Once you have made your DSN selection, and the table and template you want to generate against, you simply put the path to the cfcs in the path field. So if you were generating user components under the /com/user directory and your user bean will be named user.cfc, enter "com.user.user". Now just click generate and the tabs should populate on the right with the code for you to copy/paste into your IDE. Pretty damn easy right?
There is one other option, which is to remove extra line breaks. I am not sure why this occurs but in some cases the code appears with extra line breaks. If so, just select this option and they will be removed for you (you will need to re-click on the "generate" button).
Looking at the Code
Just a side note, but part of making my code work nicely with Flex and Cairngorm (including the automatic conversion of component to value object) meant a pretty substantial refactoring of my cfcs, but it made a much stronger design IMO. I actually did have the HTML version using this, but I never got around to releasing it. The nice thing was that I was able to get the app down to only only a handful of service methods, and the code is much more flexible I believe now.
I also intend to also release the mxml when I do the final release of the project so that people can edit the actual Flex code (this is open source after all).
Looking for Feedback
I had a handful of testers help me this weekend so that I could feel comfortable releasing this. I did have one user who had a problem with the install when it required a mapping. It did eventually work, but I would like some feedback on that. Also, would love feedback on the new features or any feature suggestions. Lastly, I have heard most users are modifying the XSL templates, which is great and what I intended. I would love it, if you have done this, if you would share your templates and we could make a library of them so that people could add them as options to their templates menu. So email me if you would like to share your templates with the project.
Looking forward to the new version, Brian - I've gotten a lot of mileage out of the existing one for places where Reactor won't do.
Also, sorry, the code zip has been added to the post. It can also be downloaded from Subversion.
Send failed
Client.Error.MessageSend
Fault occured in GetTemplateCommand
Send failed
Client.Error.MessageSend
Fault occured in GetTemplateCommand
I had to press okay 6 times to get to the app. At that point I had nothing loaded in the interface.
Any ideas what I am doing wrong?
Josen
thanks for the generator.
I' downloaded the code generator into the webroot: http://localhost:8500/cfcgenerator/index.cfm
Changed the password and appended the ?reload=true var.
and still keep getting an error:
=====================
<code>
RangeError: Index '0' specified is out of bounds.
at mx.collections::ListCollectionView/getItemAt()
at mx.collections::ListCollectionView/http://www.adobe.com/2006/actionscript/flash/proxy::getProperty()
at com.commands::GetDatasourcesCommand/result()
at mx.rpc::AsyncToken/http://www.adobe.com/2006/flex/mx/internal::applyResult()
at mx.rpc.events::ResultEvent/http://www.adobe.com/2006/flex/mx/internal::callTokenResponders()
at mx.rpc::AbstractOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()
at mx.rpc::Responder/result()
at mx.rpc::AsyncRequest/acknowledge()
at ::NetConnectionMessageResponder/NetConnectionChannel.as$37:NetConnectionMessageResponder::resultHandler()
at mx.messaging::MessageResponder/result()
</code>
=============================
Any idea what could be the issue.
Installed:
Windows 2k server
ColdFusion 7.0.2
~Cheers
I got MSSQL 2K, Windows 2k server and ColdFusion 7.0.2 installed.
I get the error using Firefox or Opera but not error when using IE. But still the no DNS on the drop down selection in any browser.
Could it be that I'm using 2k Windows server?
Anyway, thanks again
~Cheers
<cfdump var="#createObject('component','cfcgeneratorFlex.com.cf.model.generatorRemote').getDSNs()#">
<cfdump var="#createObject('component','cfcgenerator.com.cf.model.generatorRemote').getDSNs()#">
For example, the code generator creates the coldspring XML configuration file. Now, I've only ecently become aware of ColdSpring, so I'm not entirely sure how I need to use this with a Flex app, or if I use it at all and just use RemoteObject to talk directly to the service CFCs.
Any help you can offer would be appreciated.
Nick, the generator uses Flex and Cairngorm but does not currently (unless anyone has any templates to donate :) generate code specifically for use *with* Flex or Cairngorm. You could use the generated CF code as the back-end to a Flex app however...the only change that would be necessary would be to add some cfproperty tags to the generated beans (a change that I intend to make soon).
Is Mach-II still needed for this? I do not have it on this box is why I ask and recall it being needed for the other version.
Now that it is working I notice that the Oracle queries are pulling out tables that are outside of the default tablespace for that user used for the DSN connection. Just off the top of my head if the owner is not needed then this query I think would return table names for the default table space:
SELECT DISTINCT TNAME TABLE_NAME, 'TABLE' TABLE_TYPE FROM COL
It at least seems to work with that in my minimal testing.
Any fix for the send failed message listed earlier by Josen. I'm running developer edition CF 7.0.2 with multiple instances of CF. The test.cfm dump you mentioned earlier returns an array of five datasources which sounds right. I have used this introspection before so I know I have the password right etc. Is there some kind of flash security setting or how do I debug this? Thanks for your contribution to the community.
Adam
Also,hHave you pulled the latest version from RIAForge or Google Code?
Oddly, I had it running not long ago. I believe I had to reinstall CF since the last time I saw it running, but I am updated to 7.02. I checked the flex config file and set use-mappings to true.
In attempting to diagnose the nature of my problem, I instantiated an adminAPIfacade. No problem there. I called its getDatasources() method. No problem there. When I instantiate the generatorRemote cfc and call its getDSNs() method, I get the following error:
Element ADMINAPIFACADE is undefined in a Java object of type class [Ljava.lang.String; referenced as
It points me to line 31 of the generatorService.cfc, which is the getDSNs function. All it does is call the adminAPIfacade's getDatasources() function, which I seem to be able to run just fine outside the generatorService.
Any clues as to what's going on here? I need to disintegrate some varmants!
@Dave, The CF error you list sounds like simply that the application scope isn't in the application scope (since the remote facade uses the app scoped services).
I wouldn't spend to much time focusing on the CF since the error you get is a send failed, which is a Flex error (the other ones look like "Error occurred in getDatasourcesCommand" or something along those lines). The send failed seems to be exclusively a communication issue between Flex and CF. I am not sure where the issue would be as this is typically if CF isn't at 7.0.2 or a the mapping issue (you have a CF mapping called "cfcgenerator"?). Feel free to email me offline and I will do my best to help.

