So I've been using a basic template for components for the past year or so and I figured I would put it up here to help encourage lazy coding =).
<!---
PURPOSE:
REQUIREMENTS:
CREATED BY: RICHARD A HOSKA (developer email address)
DATE: /2007
TASK ORDER:
COPYRIGHT: 2007
REPOSITORY:
TO DO:
--->
<!---
any comment blocks in lowercase should be removed or replaced, they are simply here
to give information on settings to be held in component
--->
<!---
display name: friendly name for the cfc
output: defaults to yes to allow for html output for debugging purposes
hint: friendly description of what the cfc does
--->
<cfcomponent displayname="" output="yes" hint="">
<!--- what does it do
ACCESS: - type of function (secure, remote, private, public)
ACCEPT: parameters that are accepted
REQUIRED: parameters that are required
RETURN: what is returned
IF AN ERROR OCCURS, RETURNS A STRING WITH DEBUGGING INFORMATION
--->
<cffunction name=""
access=""
returntype="any"
output="true"
displayname="" hint="">
<!--- DEFINE ARGUMENTS --->
<cfargument name="" type="" required="" default="" displayname="" hint="">
<!--- DEFINE VARS USED EXCLUSIVLY BY THIS FUNCTION --->
<cfset var returnVariable = "">
<cfset var errorMessage = "">
<cfset var debug = FALSE>
<!--- DEBUGGING INFORMATION --->
<cfif debug>
<cfdump label="name of function Arguments:" var="#arguments#">
</cfif>
<!--- DATA VALIDATION --->
<!--- IF THERE WERE NO ERRORS --->
<cfif errorMessage EQ "">
<cftry>
<!--- DO WHAT EVER --->
<!--- SET RETURN VARIABLE --->
<cfset returnVariable = >
<cfcatch type="any">
<cfset errorMessage = #cfcatch.Message# & #cfcatch.Detail#>
</cfcatch>
</cftry>
</cfif>
<!--- IF AN ERROR MESSAGE HAS BEEN GENERATED, PLACE IT IN THE RETURN VARIABLE --->
<cfif errorMessage NEQ "">
<cfset returnVariable = errorMessage>
</cfif>
<!--- RETURN RETURN VARIABLE --->
<cfreturn returnVariable>
<!--- DEBUGGING INFORMATION --->
<cfif debug>
<cfdump label="setAlert returnVariable:" var="#returnVariable#">
</cfif>
</cffunction>
</cfcomponent>
No comments:
Post a Comment