| | 50 | |
| | 51 | == !CopyToScope(scope:struct, listOfEventKeys:string [,arrayOfDefaults:array]) == |
| | 52 | |
| | 53 | ==== Description: ==== |
| | 54 | |
| | 55 | Populates the scope with event values matched in the listOfEventKeys, and uses an optional array to set default values according to position. This method can replace many Event.getValue() statements with a single line of code. |
| | 56 | |
| | 57 | |
| | 58 | ==== Returns: ==== |
| | 59 | |
| | 60 | Void |
| | 61 | |
| | 62 | ==== Arguments: ==== |
| | 63 | |
| | 64 | Scope: (required) - A struct or component instance to be populated. |
| | 65 | |
| | 66 | ListOfEventKeys: (required) - a comma delimited list of keys to look for in the event. Any key not found will be defaulted with an empty string, or if the arrayOfDefaults was passed, the value of the array position matching the position of the current list item. |
| | 67 | |
| | 68 | ArrayOfDefaults: (optional) - An array of values used as defaults. The first position in the array is the default for the first position in the listOfEventKeys list. This array does not have to have the same length as the listOfEventKeys and if no array item is found the empty string will be used as the default. |
| | 69 | |
| | 70 | ==== Example: ==== |
| | 71 | |
| | 72 | {{{ |
| | 73 | <!-- Someview.cfm ---> |
| | 74 | |
| | 75 | <cfset defaultArray = ["DefaultForFoot", "DefaultForHand"] /> |
| | 76 | <cfset event.copyToScope(variables, "foot,hand,xe.nested", defaultArray) /> |
| | 77 | |
| | 78 | <!--- the variables scope now contains foot:DefaultForFoot, hand:DefaultForHand, xe.nested:"" ---> |
| | 79 | }}} |