Looks good, though there's no reason not to use CFPARAM for CFIF isDefined()
CFSET combos:

<cfparam name="attributes.cfg" default="#structNew()#" />
<cfparam name="attributes.cfg.errorpage"       default="/error.cfm">
<cfparam name="attributes.cfg.banners"         default="yes"
type="boolean">

<cfparam name="attributes.cfg.subthing" default="#structNew()#">
<cfparam name="attributes.cfg.subthing.color"  default="#000000">
<cfparam name="attributes.cfg.subthing.value"  default="bob">

> -----Original Message-----
> From: Jim McAtee [mailto:[EMAIL PROTECTED]
> Sent: Thursday, April 15, 2004 1:39 PM
> To: CF-Talk
> Subject: Testing for existence of and defaulting substructs
>
> I've got an application where page-generation tags are passed a
> configuration struct.  This struct contains a substruct.  
> What's the best
> way to test for the existence of the substruct?
>
> Right now I've got the following, which works, but I'm not sure it's
> really best.
>
> <cfif not IsDefined("attributes.cfg")>
>   <cfset attributes.cfg = StructNew()>
> </cfif>
> <cfparam name="attributes.cfg.errorpage"       default="/error.cfm">
> <cfparam name="attributes.cfg.banners"         default="yes"
> type="boolean">
>
> <cfif not IsDefined("attributes.cfg.subthing")>
>   <cfset attributes.cfg.subthing = StructNew()>
> </cfif>
> <cfparam name="attributes.cfg.subthing.color"  default="#000000">
> <cfparam name="attributes.cfg.subthing.value"  default="bob">
>
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to