Created
April 29, 2011 00:36
-
-
Save dustinmartin/947636 to your computer and use it in GitHub Desktop.
Revisions
-
Dustin Martin revised this gist
Apr 29, 2011 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,9 @@ <cfscript> public void function populate(required struct memento, boolean trustedSetter=false, string include="", string exclude="", string disallowConversionToNull=""){ var object = this; var key = ""; -
Dustin Martin revised this gist
Apr 29, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -46,6 +46,6 @@ public void function populate(required struct memento, } } } } } </cfscript> -
Dustin Martin revised this gist
Apr 29, 2011 . 2 changed files with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,8 @@ <cfscript> if(form.value== ""){ object.setValue1( javacast("null","") ); } else { object.setValue1(form.value); } </cfscript> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ <cfscript> object.populate( memento = form, disallowConversionToNull = "someProperty,anotherProperty" ); </cfscript> -
Dustin Martin revised this gist
Apr 29, 2011 . 1 changed file with 47 additions and 47 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,51 +1,51 @@ <cfscript> public void function populate(required struct memento, boolean trustedSetter=false, string include="", string exclude="", string disallowConversionToNull=""){ var object = this; var key = ""; var populate = true; // Populate Bean for(key in memento){ populate = true; // Include List? if( len(include) AND NOT listFindNoCase(include,key) ){ populate = false; } // Exclude List? if( len(exclude) AND listFindNoCase(exclude,key) ){ populate = false; } // Populate? if( populate ){ // Check if the setter exists or if trusted setting is on if( structKeyExists(object,"set" & key) or trustedSetter ){ // If the value is blank it might be converted to null if( isSimpleValue(memento[key]) && trim(memento[key]) == "" ){ // Check if this value should be kept as a string instead of converted to null if( len(disallowConversionToNull) AND NOT listFindNoCase(disallowConversionToNull,key) ){ evaluate("object.set#key#(memento[key])"); } else { // Set the value to null evaluate('object.set#key#(javacast("null",""))'); } } else { evaluate("object.set#key#(memento[key])"); } } } } // End for loop } </cfscript> -
Dustin Martin revised this gist
Apr 29, 2011 . 3 changed files with 9 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,8 @@ <cfscript> if(form.value== ""){ object.setValue1( javacast("null","") ); } else { object.setValue1(form.value); } </cfscript> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1,3 @@ <cfscript> object.populate(form); </cfscript> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,6 @@ <cfscript> object.populate( memento = form, disallowConversionToNull = "someProperty,anotherProperty" ); </cfscript> -
Dustin Martin revised this gist
Apr 29, 2011 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ <cfscript> public void function populate(required struct memento, boolean trustedSetter=false, string include="", @@ -46,4 +47,5 @@ public void function populate(required struct memento, } } } // End for loop } </cfscript> -
Dustin Martin revised this gist
Apr 29, 2011 . No changes.There are no files selected for viewing
-
Dustin Martin created this gist
Apr 29, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,49 @@ public void function populate(required struct memento, boolean trustedSetter=false, string include="", string exclude="", string disallowConversionToNull=""){ var object = this; var key = ""; var populate = true; // Populate Bean for(key in memento){ populate = true; // Include List? if( len(include) AND NOT listFindNoCase(include,key) ){ populate = false; } // Exclude List? if( len(exclude) AND listFindNoCase(exclude,key) ){ populate = false; } // Populate? if( populate ){ // Check if the setter exists or if trusted setting is on if( structKeyExists(object,"set" & key) or trustedSetter ){ // If the value is blank it might be converted to null if( isSimpleValue(memento[key]) && trim(memento[key]) == "" ){ // Check if this value should be kept as a string instead of converted to null if( len(disallowConversionToNull) AND NOT listFindNoCase(disallowConversionToNull,key) ){ evaluate("object.set#key#(memento[key])"); } else { // Set the value to null evaluate('object.set#key#(javacast("null",""))'); } } else { evaluate("object.set#key#(memento[key])"); } } } } // End for loop } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ if(form.value== ""){ object.setValue1( javacast("null","") ); } else { object.setValue1(form.value); } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ object.populate(form); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ object.populate( memento = form, disallowConversionToNull = "someProperty,anotherProperty" );