Backwards Compatibility on getValue and structs


Prior to 3.0 m5 I was able to use event.getValue to pull a struct key
using a string for example:

event.getValue("xe.something") //Where xe is a struct with a number of
values in it.

That would get me the value of the string in that struct. In 3.0 m5 it
will throw an error saying that the key doesn't exists, becuase it
only sees the struct "xe" in the collection. Is it possible to have
getValue drill down into the struct and return the value? Here is a
rewritten getValue that will return the string the way it used to.

  <cffunction name="getValue" returntype="Any" access="Public" hint="I
Get a value from the request collection." output="false">
    <cfargument name="name" type="any" required="true"
hint="Name of the variable to get from the request collection">
    <cfargument name="defaultValue" type="any" required="false"
default="NONE" hint="Default value to return if not found.">
    <cfargument name="private" type="boolean" required="false"
default="false" hint="Use public or private request collection"/>
      var collection = instance.context;
      var split='';
      var rtn='';
      var i='';

      if( arguments.private ){ collection = instance.privateContext; }

      if( structKeyExists(collection, ){
        return collection[];

      else if(find(".",{
        for(i=1; i<=arraylen(split);i++){
        return rtn;

      else if ( isSimpleValue(arguments.defaultValue) and
arguments.defaultValue eq "NONE" ){
        $throw("The variable: is undefined in the request
             "Default: #arguments.defaultValue#,
Private:#arguments.private#, Keys
        return arguments.defaultValue;

This was changed and documented as it we wanted a higher performance on this area. However, if you still want that functionality, you can build a request context decorator and use the function you used above.

Luis F. Majano
Ortus Solutions, Corp

ColdBox Platform:
Linked In:
IECFUG Manager:

Thanks! Will do that.