Site of the Day 6/20/2010

Here is the ultimate ColdFusion resource.

http://www.carehart.org/cf411/

Site of the Day 6/17/2010

I think I do these posts in batches because I’m so busy in my day job ūüôā Here is a good link concerning developing Object-oriented ColdFusion.

http://www.dfwcfug.org/blog/2010/02/09/Recording-list-for-Head-First-Design-Patterns-for-CFML-presentations

Flex Remote Object examples

  • I’m going to put my notes on how to have RemoteObject work for Adobe Flex Builder 3 for the desktop and server.¬† I personally like the idea of coding on the server since there are less surprises.
  • 1.) Creating an Application from your desktop¬†

  • Following these steps when creating your flex project.¬†project name : test_rs1¬†project location : d:\\cf9\wwwroot\apps\flex\test_rs1¬†

    Application Type : Web Application 

    Application server type: ColdFusion 

    Use remote object access service [ checked ] 

    ColdFusion Flash Remoting [ checked ] 

    ColdFusion Installation type: standalone 

    Web Root: d://cf9/wwwroot 

    Root URL: http://localhost:8500/ 

    ColdFusion WAR: d:/cf9/wwwroot/cfusion-ear/cfusion-war/ 

    Main source folder: src 

    Output folder URL: bin-debug 

    * Flex App: I copied this code and compiled the code via the ‘run’ button.¬†

    <?xml version=”1.0″ encoding=”utf-8″?>¬†

    <mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml”¬†

    layout=”absolute” viewSourceURL=”srcview/index.html”>¬†

    <mx:Script> 

    <![CDATA[ 

    import mx.controls.Alert; 

    import mx.rpc.events.FaultEvent; 

    import mx.rpc.Fault; 

    import mx.rpc.events.ResultEvent; 

    // send 

    public function WelcomeMsg():void { 

    Alert.show(test_name.text); 

    ws.WelcomeMsg(test_name.text ); 

    } 

    // result 

    private function onResult( e : ResultEvent ) :void { 

    msg.text = e.result.toString(); 

    } 

    // error msg 

    private function onFault( e : FaultEvent ) :void { 

    msg.text = e.fault.faultString; 

    } 

    ]]> 

    </mx:Script> 

    <mx:RemoteObject id=”ws”¬†

    destination=”ColdFusion”¬†

    source=”apps.flex.test_rs1.src.NEWCFComponent” >¬†

    <mx:method name=”WelcomeMsg”¬†

    result=”onResult(event)”¬†

    fault=”Alert.show(event.fault.message, ‘Erro’)” />¬†

    </mx:RemoteObject> 

    <!–¬†

    <mx:method name=”WelcomeMsg”¬†

    result=”onResult(event)”¬†

    fault=”Alert.show(event.fault.message, ‘Erro’)” />¬†

    –>¬†

    <mx:Button x=”284″ y=”10″ label=”Get Welcome Message.”¬†

    click=”WelcomeMsg()” />¬†

    <mx:TextInput id=”msg” x=”481″ y=”10″ width=”300″ />¬†

    <mx:TextInput id=”test_name” x=”116″ y=”10″ width=”150″ />¬†

    <mx:Label x=”10″ y=”12″ text=”Enter your name:” />¬†

    </mx:Application>

    * ColdFusion CFC: Save this cfc as [NEWCFComponent.cfc] in the same folder as src. You will notice that I append to a log file so I can verify that the cfc is being executed.

    <cfcomponent displayname=”CF_Service” output=”false”>¬†

    <cffunction access=”remote” returntype=”string”>
    <cfargument required=”yes” default=”default message… “>¬†

    <cfset v_now = Now() & ” <br />” >
    <cffile action=”append” addnewline=”yes”
    file=”#GetDirectoryFromPath(GetBaseTemplatePath())#cfc_log_file.html”
    output=”#v_now# date=YO, #test_name#!” fixnewline=”no” >¬†

    <cfreturn “YO, #test_name#!”>
    </cffunction> 

    </cfcomponent> 

    * Test CFC: One should make sure one doesn’t get an error from this specific method in the CFC. One should use default values for all of the CFC arguments.¬†

    http://localhost:8500/apps/flex/test_rs1/src/NEWCFComponent.cfc?method=WelcomeMsg 

    * Run a Flex Application via the ‘RUN’ button. After you compile the application, it will launch a browser of the flex page. One will put your ‘name’ in the first box and¬†click on the button. You will notice¬†the ‘YO’ and your name in the second box coming from the cfc.

    https://localhost:8500/flex/test_rs2/bin-debug/test_rs2.html

  • ¬†

    2.) Create a Flex Application on your web server 

  • * Following these steps when creating your flex project.project name : test_rs1¬†project location : \\[server-name]\reg\apps\flex\test_rs1¬†

    Application Type : Web Application 

    Application server type: ColdFusion 

    Use remote object access service [ checked ] 

    ColdFusion Flash Remoting [ checked ] 

    ColdFusion Installation type: J2EE

    Web Root: \\[server_name]\regroot\

    Root URL: https://domain_name.com/

    ColdFusion WAR: \\[server_name]\regroot\cfusion-ear\cfusion-war\

    Main source folder: src 

    Output folder URL: bin-debug 

    * Flex App: I copied this code and compiled the code via the ‚Äėrun‚Äô button.

    <?xml version=”1.0″ encoding=”utf-8″?>

    <mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml&#8221;

    layout=”absolute” viewSourceURL=”srcview/index.html”>

    <mx:Script>

    <![CDATA[

    import mx.controls.Alert;

    import mx.rpc.events.FaultEvent;

    import mx.rpc.Fault;

    import mx.rpc.events.ResultEvent;

    // send

    public function WelcomeMsg():void {

    Alert.show(test_name.text);

    ws.WelcomeMsg(test_name.text );

    }

    // result

    private function onResult( e : ResultEvent ) :void {

    msg.text = e.result.toString();

    }

    // error msg

    private function onFault( e : FaultEvent ) :void {

    msg.text = e.fault.faultString;

    }

    ]]>

    </mx:Script>

    <mx:RemoteObject id=”ws”

    destination=”ColdFusion”

    source=”flex.test_rs2.src.NEWCFComponent” >

    <mx:method name=”WelcomeMsg”

    result=”onResult(event)”

    fault=”Alert.show(event.fault.message, ‘Erro’)” />

    </mx:RemoteObject>

    <mx:Button x=”284″ y=”10″ label=”Get Welcome Message.”

    click=”WelcomeMsg()” />

    <mx:TextInput id=”msg” x=”481″ y=”10″ width=”300″ />

    <mx:TextInput id=”test_name” x=”116″ y=”10″ width=”150″ />

    <mx:Label x=”10″ y=”12″ text=”Enter your name:” />

    </mx:Application>

    ColdFusion CFC: Save this cfc as [NEWCFComponent.cfc] in the same folder as src. You will notice that I append to a log file so I can verify that the cfc is being executed.

    <cfcomponent displayname=”CF_Service” output=”false”>

    <cffunction name=”WelcomeMsg” access=”remote” returntype=”string”>

    <cfargument name=”test_name” type=”string” required=”yes” default=”default message… “>

    <cfset v_now = Now() & ” <br />” >

    <cffile action=”append” addnewline=”yes”

    file=”#GetDirectoryFromPath(GetBaseTemplatePath())#cfc_log_file.html”

    output=”#v_now# date=YO, #test_name#!” fixnewline=”no” >

    <cfreturn “YO, #test_name#!”>

    </cffunction>

    </cfcomponent>

    * Test CFC: One should make sure one doesn’t get an error from this specific method in the CFC. One should use default values for all of the CFC arguments. 

    http://[domain-name.com]/flex/test_rs1/src/NEWCFComponent.cfc?method=WelcomeMsg 

    * Run a Flex Application via the ‚ÄėRUN‚Äô button. After you compile the application, it will launch a browser of the flex page. One put you ‚Äėname‚Äô in the first box and click on the button. You will notice the ‚ÄėYO‚Äô and your name in the second box.

    https://[domain-name.com]/flex/test_rs2/bin-debug/test_rs2.html

  • Site of the Day 6/15/2010

    Here is a good site using ColdFusion and Flex.

    http://flexcf.com/home

    Site of the Day 6/6/2010

    Here is a simple article about Flex and ColdFusion RemoteObject/WebServices.

    http://macmartine.com/blog/2008/04/flex_and_coldfusion_remoteobje.html

    Site of the Day 5/12/2010

    Here is a great demo using an Open Source Java facial recognition software (jar) with ColdFusion.

    http://cfsilence.com/blog/client/index.cfm/2010/1/21/Facial-Recognition-in-14-Lines-Of-ColdFusion

    Site of the Day 5/11/2010

    I like this demo from Raymond Camden’s site about how to create images from a URL. This means I could create snapshots of my application for training purposes.

    http://www.coldfusionjedi.com/index.cfm/2007/6/13/ColdFusion-8-URL-Thumbnails