This feature lets you set your CFC property as simple variable assignment, without specifying the setters. That is, you can set the property by setting the property field rather than by invoking the setter method for the property.
Similarly, the property value can be accessed by referencing the property name, rather than by invoking the getter for the property.
Example
Application.cfc
component
{
this.name = "MyApplication";
this.invokeImplicitAccessor = true;
}
|
employee.cfm
<cfscript>
emp = new emp();
emp.firstname = "Tom";
emp.lastname = "Nash";
emp.age = 30;
writeOutput("First Name = " & emp.firstname & "<br>");
writeOutput("last Name = " & emp.emp.lastname & "<br>");
writeOutput("Age = " & emp.age & "<br>");
</cfscript>
|
employee.cfc
<cfcomponent accessors="TRUE">
<cfproperty name="firstname" type="string" setter="true"/>
<cfproperty name="lastname" type="string" setter="false"/>
<cfproperty name="age" type="numeric"/>
<cffunction name="onMissingMethod">
<cfargument name="missingMethodName"/>
<cfargument name="missingMethodArguments"/>
<cfoutput>
onMissingMethod() called for method call -#arguments.missingMethodName#
<hr>
</cfoutput>
</cffunction>
</cfcomponent>
|
In the example, CFC Implicit notation works only if you set invokeImplicitAccessor in the Application.cfc to true. Otherwise, the values are posted to the This scope of the component.