Site of the Day 8/16/2010

AMF for the Apple iPhone

http://egnaro.com/post.cfm/amf-for-iphone

Site of the Day 6/21/2010

Here is a great site from Adobe about learning about their products.

http://tv.adobe.com/

Site of the Day 6/20/2010

Here is the ultimate ColdFusion resource.

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

Site of the Day 6/19/2010

Here is an article on how to use jQuery from Google (CDN) and your local web server.

http://www.coldfusioning.com/index.cfm/2010/7/9/Load-jQuery-From-Google-Without-Risk-of-Breaking-Your-Site

Site of the Day 6/18/2010

Here is some information concerning ColdFusion 9.0.1.

http://www.aaronwest.net/blog/index.cfm/2010/7/13/ColdFusion-901-Released

Documentation of changes to the Language.

http://www.adobe.com/support/documentation/en/coldfusion/901/cf901features.pdf

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/8/2010

    This is the link to Adobe Developers site.

    http://www.adobe.com/devnet/

    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 6/2/2010

    Here is an article how to use ColdFusion 9 services with Flex.

    http://balajisridhar.wordpress.com/2009/11/27/how-to-consume-cfaas-using-flex-client/

    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

    Site of the Day 5/5/2010

    Here is nice little tip concerning ColdFusion and PING.

    http://cfsearching.blogspot.com/2010/05/ping-with-coldfusion-and-net.html

    Flex and CFMX 7 using an Array of queries

    I am starting to experiment on how to send an ‘array of queries’ from CFMX 7 with 1 httpservice call from Flex. This service will send 1 xml packet of data for 4 data grids. So, instead of sending 4 httpserice calls from flex to cfmx and sending back 4 xml packets, I thought maybe less data and less requests would speed up the response time. I will add more content as I finish this code (8/26/2009).

    1.) You will notice that I modified querytoxml in cflib for my purposes.

    Flex (send data to cfmx)
    =============================================================================
    <mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml&#8221; layout=”absolute”
    creationComplete=”_init_app()”
    width=”1280″ height=”100%”
    themeColor=”#D6DADC” backgroundGradientAlphas=”[1.0, 1.0]”
    backgroundGradientColors=”[#7AB4F6, #C2DCF8]” >

    <mx:Script>
    <![CDATA[

    // get XML to data grids
    public function _init_app(): void {

    idloadSHOWALL.send();

    } // end of init….

    // show errors from server
    public function handleFault(event:FaultEvent,a_descr:String):void {

    Alert.show(event.fault.faultString + ” ” + a_descr, “Error”);
    } // end of handle fault…

     
    ]]>
    </mx:Script>

     

    <mx:HTTPService
    id=”idloadSHOWALL”
    url=”/flex/get_datagrids.cfm”
    useProxy=”false” showBusyCursor=”true”
    result=”set_datagrids(event);”
    fault=”handleFault(event,’Get Data Grid’);” />

    CFMX 7 (build xml and send back to Flex)
    ===============================================================================

    <cfparam name=”url.a_tabid” type=”any” default=”” >
    <cfparam name=”url.a_deptid_emplid” type=”any” default=”” >
    <cfparam name=”url.a_panelid” type=”any” default=”” >
    <cfparam name=”url.a_sort” type=”any” default=”1″ >

    <cfsetting enablecfoutputonly=”yes” showdebugoutput=”No”>

    <cfsilent>

    <cfscript>
    /**
    * Generates an XMLDoc object from a basic CF Query.
    *
    * @param query The query to transform. (Required)
    * @param rootElement Name of the root node. (Default is “query.”) (Optional)
    * @param row Name of each row. Default is “row.” (Optional)
    * @param nodeMode Defines the structure of the resulting XML. Options are 1) “values” (default), which makes each value of each column mlText of individual nodes; 2) “columns”, which makes each value of each column an attribute of a node for that column; 3) “rows”, which makes each row a node, with the column names as attributes. (Optional)
    * @param basicinfo Y/N (Y=default) Basic information. (Optional)
    * @param v_no_record_col Compare this column name if there is no records. (Optional)
    * @param v_no_record_descr Add this description to the column name if there is no records. (Optional)

    * @return Returns a string.
    * @author Patrick Whittingham
    * @version 3, August 2009
    */
    function queryToXML(query){

    //the default name of the root element
    var root = “query”;
    //the default name of each row
    var row = “row”;
    //make an array of the columns for looping
    var cols = listToArray(query.columnList);
    var v_rows = query.recordCount;
    //which mode will we use?
    var nodeMode = “values”;
    // default : basic info
    var basicinfo = “Y”;
    var v_no_record_col = “”; var v_no_record_descr = “No Data Found”;
    //vars for iterating
    var ii = 1; var rr = 1;
    //vars for holding the values of the current column and value
    var thisColumn = “”; var thisValue = “”;
    //a new xmlDoc
    var xml = xmlNew();
    //if there are 2 arguments, the second one is name of the root element
    if(structCount(arguments) GTE 2) root = arguments[2];
    //if there are 3 arguments, the third one is the name each element
    if(structCount(arguments) GTE 3) row = arguments[3];
    //if there is a 4th argument, it’s the nodeMode
    if(structCount(arguments) GTE 4) nodeMode = arguments[4];
    //if there is a 5th argument, its the basic info.
    if(structCount(arguments) GTE 5) basicinfo = arguments[5];
    //if there is a 6th argument.
    if(structCount(arguments) GTE 6) v_no_record_col = arguments[6];
    //if there is a 7th argument.
    if(structCount(arguments) GTE 7) v_no_record_descr = arguments[7];

    //create the root node
    xml.xmlRoot = xmlElemNew(xml,root);
    //capture basic info in attributes of the root node
    if (basicinfo eq “Y” ) {
    xml[root].xmlAttributes[“columns”] = arrayLen(cols);
    xml[root].xmlAttributes[“rows”] = query.recordCount;
    }
    //loop over the recordcount of the query and add a row for each one
    for(rr = 1; rr LTE query.recordCount; rr = rr + 1){
    arrayAppend(xml[root].xmlChildren,xmlElemNew(xml,row));
    //loop over the columns, populating the values of this row
    for(ii = 1; ii LTE arrayLen(cols); ii = ii + 1){
    thisColumn = lcase(cols[ii]);
    thisValue = query[cols[ii]][rr];
    switch(nodeMode){
    case “rows”:
    xml[root][row][rr].xmlAttributes[thisColumn] = thisValue;
    break;
    case “columns”:
    arrayAppend(xml[root][row][rr].xmlChildren,xmlElemNew(xml,thisColumn));
    xml[root][row][rr][thisColumn].xmlAttributes[“value”] = thisValue;
    break;
    default:
    arrayAppend(xml[root][row][rr].xmlChildren,xmlElemNew(xml,thisColumn));
    xml[root][row][rr][thisColumn].xmlText = thisValue;
    }
    }
    } // end of rr loop….

    // NO RECORDS FOUND
    if (v_rows eq 0) {
    arrayAppend(xml[root].xmlChildren,xmlElemNew(xml,row));
    thisColumn = lcase(cols[ii]); thisValue = “”; rr = 1;
    //loop over the columns, populating the values of this row
    for(ii = 1; ii LTE arrayLen(cols); ii = ii + 1){
    thisColumn = lcase(cols[ii]); thisValue = “”;
    if (UCASE(thisColumn) eq UCASE(v_no_record_col) ) { thisValue = v_no_record_descr; }
    switch(nodeMode){
    case “rows”:
    xml[root][row][rr].xmlAttributes[thisColumn] = thisValue;
    break;
    case “columns”:
    arrayAppend(xml[root][row][rr].xmlChildren,xmlElemNew(xml,thisColumn));
    xml[root][row][rr][thisColumn].xmlAttributes[“value”] = thisValue;
    break;
    default:
    arrayAppend(xml[root][row][rr].xmlChildren,xmlElemNew(xml,thisColumn));
    xml[root][row][rr][thisColumn].xmlText = thisValue;
    }
    }
    } // end of if…
    //return the xmlDoc
    return xml;
    }
    </cfscript>

    <!— show all —>
    <cfset v_tabs = “” >
    <cfif url.a_sort eq “1” > <cfset url.a_sort = “Ttabno, Tdept ” >
    <cfelse> <cfset url.a_sort = “Tdept, Ttabno ” >
    </cfif>
    <cfinvoke component=”cat”
    method=”get_show_all” argumentcollection=”#url#” returnvariable=”ret_showall” />

    <cfdump var=”#ret_showall#”>

    <cfscript>
    v_count = 0; v_content = “”;
    v_rows = ArrayLen(ret_showall);
    //
    v_tab_list = ret_showall[1].columnlist; v_tab_arr = ListToArray(v_tab_list); v_row1 = ret_showall[1].RecordCount;
    v_panel_list = ret_showall[2].columnlist; v_panel_arr = ListToArray(v_panel_list); v_row2 = ret_showall[2].RecordCount;
    v_link_list = ret_showall[3].columnlist; v_link_arr = ListToArray(v_link_list); v_row3 = ret_showall[3].RecordCount;
    v_parms_list = ret_showall[4].columnlist; v_parms_arr = ListToArray(v_parms_list); v_row4 = ret_showall[4].RecordCount;
    //
    </cfscript>

    <cfset xmlObj1 = queryToXML(ret_showall[1],”rows”,”row”,”rows”,”N”,”tname”,”No Data Found”) >
    <cfset xmlObj1 = Replace(xmlObj1,’table_type=””‘,’table_type=”1″‘,’All’) >
    <cfset xmlObj2 = queryToXML(ret_showall[2],”rows”,”row”,”rows”,”N”,”pname”,”No Data Found”) >
    <cfset xmlObj2 = Replace(xmlObj2,’table_type=””‘,’table_type=”2″‘,’All’) >
    <cfset xmlObj3 = queryToXML(ret_showall[3],”rows”,”row”,”rows”,”N”,”Lurl”,”No Data Found”) >
    <cfset xmlObj3 = Replace(xmlObj3,’table_type=””‘,’table_type=”3″‘,’All’) >
    <cfset xmlObj4 = queryToXML(ret_showall[4],”rows”,”row”,”rows”,”N”,”pmname1″,”No Data Found”) >
    <cfset xmlObj4 = Replace(xmlObj4,’table_type=””‘,’table_type=”4″‘,’All’) >

    <cfset xmlobj = xmlObj1 & xmlObj2 & xmlObj3 & xmlObj4 >
    <cfset xmlobj = Replace(xmlobj,'<?xml version=”1.0″ encoding=”UTF-8″?>’,”,’All’) >
    <cfset xmlobj = Replace(xmlobj,”<rows>”,””,”All”) >
    <cfset xmlobj = Replace(xmlobj,”</rows>”,””,”All”) >
    <cfset xmlobj = ‘<?xml version=”1.0″ encoding=”UTF-8″?><rows>’ & xmlobj & ‘</rows>’ >

    </cfsilent>

    <cfsetting enablecfoutputonly=”no” />
    <cfcontent reset =”yes” type=”text/xml; charset=UTF-8″>
    <cfoutput>#xmlObj#</cfoutput>
    <cfsetting showdebugoutput=”No” >
    <cfabort>

    cfmx 9 tips/tricks

    Here is a list of new cfmx 9 tips and tricks.

    Documentation
    Configuring and Administering Adobe ColdFusion 9
    Adobe cfmx 9 CFML Reference
    Developing Adobe cfmx 9 Applications
    Installing Adobe cfmx 9
    Adobe cfmx 9 Language Reference

    Using Adobe ColdFusion Builder
    Installing Adobe ColdFusion Builder

    Trick and Tips
    Excellent CFMX 9 review
    Sneak Peek of Proxy Tags in ColdFusion 9
    ColdFusion Functionality Exposed As Services
    The New ColdFusion LOCAL Scope
    Look, No Datasource
    Sneak Peek of Proxy Tags in ColdFusion 9
    AIR, CFMX9 and SQLLite

    Flash Remoting in ColdFusion 9 is super fast!
    Changes in the XML configuration files for Flash Remoting in ColdFusion 9

    VIDEOS
    9 Videos

    cfmx 8 tips/tricks

    Here is a list of new cfmx 8 tips, trick and problems in CFMX 8.

    TIPS

    TRICKS

    PROBLEMS

    ColdFusion createObject “Component” and Pathing Performance

    Good References
    RIA Forge
    CFLIB

    ColdFusion Performance Tips

    I’m going to start to add links concerning making my CFMX faster which are not related to database issues. I will create a separate page for those tips.

    Performance tuning for ColdFusion applications
    CF911: Easier thread dumps and stack traces in CF: how and why