coldfusion - How do I append to a struct set in CFPROPERTY? -


i'm using <cfproperty /> make use of implicit getters , setters in coldfusion (railo).

however, more complex values structs , arrays, how can append these?

<cfproperty name="settings" type="struct" /> 

how can append item property called settings? if following:

<cfset setsettings(structappend(getsettings(), { "hello" = "world" })) /> 

i following error:

java.lang.nullpointerexception

am missing here? i'm new cfproperty tag , thought time saver, can't figure out.

also, bonus how set default value these complex data types?

thanks, mikey

couple things here...

<cfset setsettings(structappend(getsettings(), { "hello" = "world" })) /> 

settings struct structappend() returns boolean. struct appending before line. second, structs passed reference, meaning, if getsettings() struct, can make changes to. call getsettings() return same struct updated settings.

all need this:

<cfset structappend(getsettings(), { "hello" = "world" }) /> 

one last thing. getting null pointer exception because getsettings() starts uninitialized. in cfc, in constructor area (after properties), should set initial settings struct, this:

<cfset setsettings({}) /> 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -