Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically populate data properties with passed parameters when onMount() isn't defined #132

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions models/concerns/OnMountConcern.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,30 @@ component accessors="true" singleton {
);
} else {
/**
* Use setter population to populate our component.
* Use scope population to populate our component.
*/

// check datatypes parameters and throw error if not string, boolean, numeric, date, array, or struct
for( var paramKey IN arguments.parameters.keyArray() ){
if( !isSimpleValue( arguments.parameters[ paramKey ] )
&& !isArray( arguments.parameters[ paramKey ] )
&& !isStruct( arguments.parameters[ paramKey ] )
){
throw(
type = "MissingOnMount",
message = "The wire does NOT have onMount() function and the paramaters passed contain a
data type other than a string, boolean, numeric, date, array, or struct and cannot
be automatically inserted into the data properties. To avoid this error create an
onMount() method to handle incoming paramaters"
);
}
}

// if parameters passed in are string, boolean, numeric, date, array, or struct insert into variables.data
getPopulator().populateFromStruct(
target: this,
trustedSetter: true,
target: comp.getParent(),
memento: arguments.parameters,
excludes: ""
scope: "variables.data"
);
}

Expand Down