Joseph DeVore's Blog: ColdFusion


Viewing By Category : ColdFusion / Main
January 11, 2008
I have been doing a lot of work for Qwest Communications, Inc. lately on several of their Intranet and Internet web sites*.

One of the best projects that I've worked on so far is the Qwest.com Press Release tool. I had the chance to completely architect (using OmniGraffle and customer requirements), code (using Fusebox 5, ColdFusion, CSS, JavaScript/AJAX, Prototype JSFW, XML, SQL in Eclipse, CFEclipse, Navicat and Smultron), graphically design (Photoshop) and deploy to the staging and production servers.

Qwest was using Vignette Server for their PR tool and it worked for a long time, but it had many limitations and they outgrew it. The Vignette tool had over 12 years of legacy PR data that was stored in a ton of CSV and XML files that I had to figure out how to migrate to the new system. I wrote a custom parser to relate the CSV and XML files, parse the data from the XML, scrub it and store it in a MySQL database.

The application also has an RSS feed generator that displays all of the top 100 latest press releases. Each individual press release also has an RSS feed and link for global syndication and search engine optimization.

The Intranet based portion of this application connects to Qwest's Active Directory Servers using LDAP to authenticate users using their SSO (single sign-on). The application uses a role-based security system with different levels of access set by the administrators. The "non-publisher" can create and edit press releases, the "publisher" approves or denies them and the "administrator" has super user access to do anything he/she wants, along with the ability to manage user accounts, grant access to certain roles, set permissions and remove any published press releases.

The application consists of an Intranet based Content Management System for entering the Press Releases and uses FCKEditor's WYSIWYG tools for rich content editing. The system contains a scheduler for automated publishing based on the author's predefined date/time and many more features like internal and external media contacts per release.

I could write a lot more about the application and its features but it's time for me to sleep! It's almost 3AM - whoa!

Check out the application here if you're interested: http://press.qwestapps.com/

* Things stated are my opinions and not those of my employer. It is also possible that what I've written about will have changed by time you've read this and visited the site. Feel free to leave me any feedback!

-JD

February 24, 2007
Since my brain is consumed with Flex, Flash, ActionScript 2 and 3, ASP (Classic VB Script stylee boyee!!) and ColdFusion 8 lately - I figured I'd blog about this regular expression in case I for some reason forget regular expressions or need to point someone to this code snippet...

<!--- some XML input with no data, just a bunch of closed nodes --->

<cfsavecontent variable="xml">
<RatingServiceSelectionResponse>
   <Response>
      <ResponseStatusCode/>
      <ResponseStatusDescription/>
   </Response>
   <RatedShipment>
      <Service>
         <Code/>
      </Service>
      <RatedShipmentWarning/>
      <BillingWeight>
         <UnitOfMeasurement>
            <Code/>
            <Description/>
         </UnitOfMeasurement>
         <Weight/>
      </BillingWeight>
      <TransportationCharges>
         <CurrencyCode/>
         <MonetaryValue/>
      </TransportationCharges>
      <ServiceOptionsCharges>
         <CurrencyCode/>
         <MonetaryValue/>
      </ServiceOptionsCharges>
      <TotalCharges>
         <CurrencyCode/>
         <MonetaryValue/>
      </TotalCharges>
      <GuaranteedDaysToDelivery/>
      <ScheduledDeliveryTime/>
      <RatedPackage>
         <TransportationCharges>
            <CurrencyCode/>
            <MonetaryValue/>
         </TransportationCharges>
         <ServiceOptionsCharges>
            <CurrencyCode/>
            <MonetaryValue/>
         </ServiceOptionsCharges>
         <TotalCharges>
            <CurrencyCode/>
            <MonetaryValue/>
         </TotalCharges>
         <Weight/>
         <BillingWeight>
            <UnitOfMeasurement>
               <Code/>
               <Description/>
            </UnitOfMeasurement>
            <Weight/>
         </BillingWeight>
      </RatedPackage>
   </RatedShipment>
</RatingServiceSelectionResponse>
</cfsavecontent>

<cfscript>
// regular expression to find shorthand nodes
re='<([^\/>]*)/>';
   
// replace with tag pair
xml=reReplace(xml,re,'<\1></\1>','all');
   
// write formatted HTMl code to screen
writeOutput(htmlCodeFormat(xml));
</cfscript>

August 10, 2006
If you forget your ColdFusion Admin password, you can make the server reset it for you. To do this, you stop the CF server, rename the password.properties file to something else and start the server. This will create a new password.properties file for you automaticaly. The new admin password is: admin

December 2, 2005
This web service is pretty cool. Using the XML response is a bit of a challenge, IMO. Maybe I just need to look at the examples and the results again. Ok, after looking at it again, it's pretty straight forward - I just need to decide how I want to present the info. Anyhow, cool stuff...

<cfinvoke webservice="http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl"
method="NDFDgenByDay"
returnvariable="aString">

<cfinvokeargument name="latitude" value="47.555872"/>
<cfinvokeargument name="longitude" value="-122.001514"/>
<cfinvokeargument name="startDate" value="12/01/2005"/>
<cfinvokeargument name="numDays" value="1"/>
<cfinvokeargument name="format" value="12 hourly"/>
</cfinvoke>

<cfdump var="#xmlParse(aString)#">

http://www.weather.gov/forecasts/xml/SOAP_server/ndfdXMLclient.php?lat=38.99&lon=-77.99&product=glance&begin=2007-09-30&end=2007-09-31T00%3A00%3A00&Submit=Submit

October 13, 2005
<cfform format="flash" name="mulitselect" width="300" height="300">
   <cfformitem type="script">
      var selectOptions = function(selectBox:Object, indiciesList:String):Void {
         var options:Array = indiciesList.split(',');
         selectBox.selectedIndices=options;   
      }
   </cfformitem>
   <cfselect name="mySelectBox" multiple="yes" size="5" >
      <option value="option 1">1</option>
      <option value="option 2">2</option>
      <option value="option 3">3</option>
      <option value="option 4">4</option>
      <option value="option 5">5</option>
   </cfselect>
   
   <cfinput type="button" name="q" value="SELECT OPTIONS" onclick="selectOptions(mySelectBox, '0,1,3')">
</cfform>


If you ever have the need to select all of the options in a select box, this code does just that.

<cfform format="flash" name="mulitselect" width="300" height="300">
   <cfformitem type="script">
      var selectAllOptions = function(selectBox:Object):Void {
         var options:Array = Array();
         
         for(var i:Number=0; i <= selectBox.length; i++) {
            options.addItem(i);
         }
         selectBox.selectedIndices=options;   
      }
   </cfformitem>
   <cfselect name="mySelectBox" multiple="yes" size="5" >
      <option value="option 1">1</option>
      <option value="option 2">2</option>
      <option value="option 3">3</option>
      <option value="option 4">4</option>
      <option value="option 5">5</option>
   </cfselect>
   
   <cfinput type="button" name="q" value="SELECT ALL" onclick="selectAllOptions(mySelectBox)">
</cfform>

October 4, 2005
<cfsavecontent variable="as">
   var confirmation = function (evt)
  {
      switch (evt.detail) {
         case mx.controls.Alert.OK:
            alert("You clicked OK","OK!");
            // do something
         break;
         case mx.controls.Alert.CANCEL:
            alert("You clicked CANCEL","CANCEL!");
            // do something
         break;
      }
  }
  alert("Are you sure?", "Warning", mx.controls.Alert.OK | mx.controls.Alert.CANCEL, confirmation);
</cfsavecontent>

September 1, 2005
Looking to consolidate inline <style>'s into external stylesheets? This code will build an array of all of the CSS between <style> tags. The only thing missing from a complete solution is a recursive file loader/reader.

<cfscript>
// create array to store styles
styles=arrayNew(1);

// regular expression
re="<style>([^<]*)</style>";
// parse first result
results=reFindNoCase(re, trim(htmlToParse), 1, 1);

// loop over RE parsed results recursively
while(results.pos[1]) {
 // append style to styles array
 arrayAppend(styles, trim(mid(trim(htmlToParse), results.pos[2], results.len[2])) );

 // parse next style
 results=reFindNoCase(re, trim(htmlToParse), results.pos[2] + results.len[2],1);
}
</cfscript>

August 25, 2005
Parsing content is pretty easy with recursion and regular expressions. The following code demonstrates how to accomplish this task fairly easily.

<cfscript>
   // create ICD-9 codes list
   icd9codes='';

   // icd-9 regular expression
   re="\b([aev0-9]\d\d(\.\d\d?)?)(\s?-\s?\1)?\b";
   // parse first result
   results=reFindNoCase(re, trim(form.policy), 1, 1);

   // loop over RE parsed results recursively
   while(results.pos[1]) {
      // appen code to code list
      icd9codes=listAppend(icd9codes, trim(mid(trim(form.policy), results.pos[1], results.len[1])), " ");
      
      // parse next icd-9 in policy
      results=reFindNoCase(re,trim(form.policy),results.pos[1] + results.len[1],1);
   }
</cfscript>

August 1, 2005
So I've been messing with a bunch of stuff in MX 7 trying to figure out complex Java objects that should be getting converted to CF structures but seem to be read-only accessible to StructCount() or StructKeyList(), etc. I can't seem to read them, output them, duplicate them, dump them or set them. It's really odd. Anyhow, while messing with GetPageContext(), I found this interesting set of methods that I had no idea existed. The object: GetPageContext().getRandomNumberGenerator() contains a bunch of methods for generating random numbers:


GetPageContext().getRandomNumberGenerator().nextDouble(): 0.653134088716

GetPageContext().getRandomNumberGenerator().nextInt(): -881534180

GetPageContext().getRandomNumberGenerator().nextBoolean(): YES

GetPageContext().getRandomNumberGenerator().nextFloat(): 0.11886954

GetPageContext().getRandomNumberGenerator().nextGaussian(): 0.216899290492

GetPageContext().getRandomNumberGenerator().nextLong(): -7387478764913535202

Very interesting indeed!













Editor Login ›