HHWD Hiring ColdFusion Developers - Updated

WOW! What a year! Due to our expanding backlog of work, Honey House Web Designs is expanding our workforce. Update: We are looking for experienced CF coders, as well as subcontractors and Internet IT professionals.

If you are a Coldfusion developer who is proficient in

  • CF 8 or 9,
  • CFC beans and Data Objects,
  • CSS based designs,
  • Java
  • Server Management

If you are proficient in Flash/Flex, CFEclipse, FusionDebug, these are added bonus.

Candidates should live in the South East, (no relocation offered). Some telecommuting may be possible within a 150 mile radius in the beginning, but you must be an organized self-starter who can work without tons of oversight.

Please send your resume and project sample links to hhd - at - honeyhousedesigns.com (you know the schpeal).

Better way of Initializing from CFEclipse Bean Wizard

I have been using the CFEclipse to create the Bean, DAO, and Gateway CFCs. Not because it is a perfect tool, but while I am still learning how to manage working in a Framework better (and faster), the CFEclipse provides a nice foundation to start from.

Also, in the Lynda.com tutorials, David Gassner uses these wizards and customizes get/set bean cfc to be able to reinitialize the bean variables from a form. This is great and has helped me wrap my head around the easily confusing method of setter and getters. BUT! When the form doesn't have a variable that wants to be set by the bean, I have to pad cfif statements everywhere.... Not good and with large tables a real PITA. So I came up with a better way of doing it using StructKeyArrays....

Here is an example of a simple event table Bean created by CFEclipse:


<cfcomponent alias="blahblah.cfc.events">
    <cfproperty name="eventid" type="numeric" default="0">
    <cfproperty name="event" type="string" default="">
    <cfproperty name="eventdesc" type="string" default="">
    <cfproperty name="eventtime" type="string" default="">
    <cfproperty name="displayme" type="string" default="">
    <cfscript>
        //Initialize the CFC with the default properties values.
        this.eventid = 0;
        this.event = "";
        this.eventdesc = "";
        this.eventtime = "";
        this.displayme = "";
    
</cfscript>

    <cffunction name="init" output="false" returntype="events">
        <cfreturn this>
    </cffunction>
<!--- getters and setters not shown here --->

David customizes the code a bit to accept a form structure and reset the values:


<cfcomponent alias="blahblah.cfc.events">
<!--- skipped over component cfproperty --->

<cffunction name="init" output="false" returntype="events">
<cfargument name="stValues" required="no" type="struct">
<cfif isdefined('arguments.stValues')>
     <cfset this.eventid = arguments.stValues.eventid >
<cfset this.event = arguments.stValues.event >
<cfset this.eventdesc = eventdesc >
<cfset this.eventtime = arguments.stValues.eventtime >
     <cfset this.displayme = arguments.stValues.displayme >
</cfif>
<cfreturn this>
</cffunction>
<!---setters and getters not shown again --->
This is great... except in real practice, if the form variable doesn't exists, like for checkboxes that are unchecked, or pulldowns now selected, an error gets thrown, wanting each instance of a form variable to be checked for existence first. Not good with large tables or complex forms.

So to fix it, instead of manually picking through and adding cfif isdefined's for each variable that may not be there, I used the form structures "FIELDNAMES" to pick out the columns that exist and assign them.


<cfcomponent alias="blahblah.cfc.events">
    <cfproperty name="eventid" type="numeric" default="0">
    <cfproperty name="event" type="string" default="">
    <cfproperty name="eventdesc" type="string" default="">
    <cfproperty name="eventtime" type="string" default="">
    <cfproperty name="displayme" type="string" default="">
    <cfscript>
    //Initialize the CFC with the default properties values.
    this.eventid = 0;
    this.event = "";
    this.eventdesc = "";
    this.eventtime = "";
    this.displayme = "";
    
</cfscript>

<cffunction name="init" output="false" returntype="events">
<cfargument name="stValues" required="no" type="struct">
    <cfset var fieldarray = arraynew(1)> <!--- to hold form structure fieldnames --->

    <cfif isdefined('arguments.stValues')>
<!--- form has fields --->
     <cfif arraylen(structkeyarray(arguments.stValues) ) gt 0>
<cfset fieldarray = structkeyarray(arguments.stValues)>
<cfloop from='1' to='#arraylen(fieldarray)#' index='i'>
<!--- skip the "submit" button and the "fieldnames" column--->
<cfif findnocase('fieldnames',fieldarray[i]) eq 0 and findnocase('submit',fieldarray[i]) eq 0>
<cfset "this.#fieldarray[i]#" = evaluate(fieldarray[i]) >
</cfif>
</cfloop>
</cfif>
     </cfif>
    <cfreturn this>
    </cffunction>
<!--- setters and getters not shown (duh) ---->

The results is a concise package that eliminates the need to re-evaluate each form field for existance.

CFCs When you must use explicit naming -- Frameworks Potential Gotcha

Since HHWD often uses test databases and testing areas for internal development servers, and online client sandboxes, we set up our application.cfc to refer to many items by reference.

Instead of using datasource='databasefoo'

We will have an application.cfc entry:

<cfset application.dsn = 'databasefoo'>

then in the CFC cfquery use

<cfquery datasource='#application.dsn#'...
since the testing database and sandbox database aren't our production databases, we want to be able to quickly update just the application.cfc and have it point to the correct database without having to do perform a find/replace across our site.

Similarly, We do the similar setups for CFCs. Since the testing server and sandboxes a different directory structure than our production area, we normally use:

and then refer to it in our code as:

This all works great .... EXCEPT when your framework/OO needs and wants an explicit reference. This would be cases where you are establishing a bean or using a returntype:

in DAOs:

<cffunction name="read" output="false" access="public" returntype="datafoo.cfc.data">
You must enter the explicit returntype. Putting the #application.cfc# in the returntype field throws a generic 500 "Server busy or starting" error. Cryptic and not particularly useful in the measure.

The same situation occurs when you declare a bean argument with the cfc as its type:

<cfargument name="bean" required="true" type="datafoo.cfc.data">

You must use the explicit reference here as well.

As you can tell, I just spent a few hours in the school of head-bangers figuring out the issue... after I did a sitewide replacement of all "datafoo.cfc." with "#application.cfc#".

Better way to set Dynamic Directory References?

I have several projects set up in the following directory structure:



\ (contains index.cfm and application.cfc)
\cfc (contains all CFCs)
\html (contains all non home page files)
\images
\includes
\config
(and so on)....

The application.cfc uses REQUEST variables to reference the page location to link to based on where the location is. This is not very good practice, but is an ancient holdover from CF5 when I first started in Coldfusion.

Here is an example:


<!--- if page location anywhere but root--->
<cfif findnocase('html/',cgi.script_name) gt 0 or
findnocase('includes/', cgi.script_name) >

<cfset request.includes='../includes/'>
<cfset request.html="../html/">
<!---(... and so on )--->
<cfelse>
<cfset request.includes='includes/'>
<cfset request.html="html/">
<!---(... and so on )--->
</cfif>

Then I use the reference:



<a href='#request.html#page.cfm'>NavLink1</a>

in my includes and pages to reference given page.

There has got to be a better way to skin this animal. While I am plowing through beans and configs, in the meantime I have several projects that I just want to perform some simple cleanup on.

Anyone got any better suggestions? The settings would need to change based on a page by page basis but aren't updated or reset by the user .

A

More Entries

BlogCFC was created by Raymond Camden. This blog is running version 5.9.1.002. Contact HHWD