2. What will we discuss?
•
Closures
–
Inline with Arrays, Lists and Structures
•
OnAbort event in Application.cfc
•
runonce attribute for cfinclude
•
Multiple FORM fields with same name
•
Component Updates
•
queryNew() and queryAddRow()
3. Closures
●
●
"An expression (typically a function) that can
have free variables together with an
environment that binds those variables (that
'closes' the expression)" - Lasse Nielsen
A closure, a function itself, can be created by
another function. The top-level function
closes the inner function and returns it to the
rest of the document.
4. Uses of closures
●
Creates Generic functions.
●
Mostly In-line supports.
●
Defines new UDF inside another UDF.
●
●
Used to build dynamic functions, and allows
inline functions to alter application behavior.
Can creates functions as an arguments.
6. Lists and structures with Inline
•
listFilter()
•
structEach()
•
structFilter()
-------------------------------------------------------------
•
isClosure()
•
isCustomFunction()
7. runonce attribute
•
•
CF10 allows new attribute runonce for cfinclude.
This attribute ensures that no matter how many
times you run <cfinclude>, it will actually include the
template only once.
•
•
Script based version of <cfinclude> also supports this
feature.
8. onabort event
●
●
●
CF10 allows new event "onabort".
Currently executing file name is passed as an
argument for this event.
This event will be fired of below three cases.
–
<cfabort>
–
<cfcontent>
–
<cflocation>
9. onabort event example
●
test.cfm contains cfabort
●
test_noabort.cfm not contains cfabort
●
test_cflocation contains cflocation tag with test_noabort.cfm file
Events fired When
test.cfm loads → onrequestStart, onabort
test_noabort.cfm → onrequestStart, onrequestEnd
test_cflocation.cfm → onrequestStart, onabort
test_noabort.cfm → onrequestStart, onrequestEnd
10. FORM Fields with same name
●
●
●
CF10 allows to save multiple values in the list
format for multiple check boxes having the
same name.
Where as for text boxes it will store in the
form of an array.
But for this we need to set
this.sameformfieldasarray = true in
Application.CFC
11. Component Updates
●
●
Implicit constructors : we can now pretend that our
component has a constructor-an implicit
constructor-even when it doesn't. This feature
allows us to quickly set values with out having to
actually write a constructor.
Method chaining:This chaining feature allows us to
call one method on a CFC and then call another
method immediately after it, in the same line of
code. This works for properties with accessors
turned on and for methods that set values in CFC.