Presentation is loading. Please wait.

Presentation is loading. Please wait.

2007 Adobe Systems Incorporated. All Rights Reserved. 1 Glenda Vigoreaux Adobe Certified Instructor roundpeg, Inc. Component Development.

Similar presentations


Presentation on theme: "2007 Adobe Systems Incorporated. All Rights Reserved. 1 Glenda Vigoreaux Adobe Certified Instructor roundpeg, Inc. Component Development."— Presentation transcript:

1 2007 Adobe Systems Incorporated. All Rights Reserved. 1 Glenda Vigoreaux Adobe Certified Instructor roundpeg, Inc. glenda@roundpeg.com Component Development in ColdFusion 8

2 2007 Adobe Systems Incorporated. All Rights Reserved. 2  Creating ColdFusion Components (CFCs)  ColdFusion Component Invocation  Instantiating ColdFusion Components  Persisting ColdFusion Components  CFCs and Object-Oriented Programming  Encapsulation  Inheritance and the Super keyword  Introspection  Component Access Control  Questions and Answers Session Outline

3 2007 Adobe Systems Incorporated. All Rights Reserved. 3  Allow you to group ColdFusion statements into user-defined functions that perform a logical unit of work  Object-based building block for building applications  Logically group data and functionality  CFCs can perform many related actions, defined in multiple methods  CFCs are more structured making the code easy to follow and troubleshoot Reviewing ColdFusion Components

4 2007 Adobe Systems Incorporated. All Rights Reserved. 4  Provide an ideal mechanism for code reuse  Can be invoked without including the code on the page  Can be called as web services by other clients using any platform  Are self-documenting through introspection  Can persist between page requests  Can be secured using roles-based security Benefits of ColdFusion Components

5 2007 Adobe Systems Incorporated. All Rights Reserved. 5 SELECT * FROM Services ORDER BY #arguments.sort# Creating ColdFusion Components

6 2007 Adobe Systems Incorporated. All Rights Reserved. 6  Creating a ColdFusion Component Walkthrough 1

7 2007 Adobe Systems Incorporated. All Rights Reserved. 7 <cfinvoke component="marketing.services" method="getServices" returnvariable="qServices"> ColdFusion Component Invocation

8 2007 Adobe Systems Incorporated. All Rights Reserved. 8  Invoking a ColdFusion Component Walkthrough 2

9 2007 Adobe Systems Incorporated. All Rights Reserved. 9  CFCs can be instantiated as objects and then invoked using object style syntax  Object type invocation is essential for CFCs with persistent properties and CFCs used multiple times  Using to create an instance  Using CreateObject() to instantiate the same component Instantiating ColdFusion Components

10 2007 Adobe Systems Incorporated. All Rights Reserved. 10  Use the tag  The CFC instance name is enclosed in pound signs (#) in the component attribute <cfinvoke component="#cfcServices#" method="getServices" returnvariable="qServices" sort="serv_id"/> Invoking Methods on a CFC instance

11 2007 Adobe Systems Incorporated. All Rights Reserved. 11  Object methods may also be invoked inline, using object.method() syntax Invoking Methods on a CFC instance

12 2007 Adobe Systems Incorporated. All Rights Reserved. 12  Invoking Components as Objects Walkthrough 3

13 2007 Adobe Systems Incorporated. All Rights Reserved. 13  CFCs may be instantiated into persistent scopes  Place components into the following scopes:  Session  Application Persisting ColdFusion Components

14 2007 Adobe Systems Incorporated. All Rights Reserved. 14  Persisting CFC Instances Walkthrough 4

15 2007 Adobe Systems Incorporated. All Rights Reserved. 15  ColdFusion is not object oriented  CFCs deliver some of the power and capabilities of objects  Some of the object-oriented features of CFCs include encapsulation, inheritance, and introspection CFCs and Object-Oriented Programming

16 2007 Adobe Systems Incorporated. All Rights Reserved. 16  The technique of incorporating both code and data into one object such as a CFC is known as Encapsulation  Encapsulation lets users pass data to and get a result from the CFC without having to understand the underlying code  Data passed to the CFC can be validated  CFCs can enforce data types, check for required parameters, and optionally assign default values Encapsulation

17 2007 Adobe Systems Incorporated. All Rights Reserved. 17  Allows a CFC to extend another CFC  Original component is called “base” or “parent” component  Component that extends another component is called the “child” component  Child component inherits the methods and properties from the parent component  Inheritance lets you build multiple specific components without rewriting the code for the basic building blocks of the components Inheritance

18 2007 Adobe Systems Incorporated. All Rights Reserved. 18  Child component uses the extends attribute to specify the parent component The Extends Attribute

19 2007 Adobe Systems Incorporated. All Rights Reserved. 19  Useful when a child and parent share the same method  Child component can use the super scope to reference the parent component methods Super keyword Services.cfc [Parent] [Function CFML code] OtherServices.cfc [Child]

20 2007 Adobe Systems Incorporated. All Rights Reserved. 20  CFCs support introspection because they can provide information about themselves  You can see information about the component by:  Displaying a component page directly in an HTML browser  Inspecting it in the Dreamweaver component browser  The information displayed includes the component’s path, property, methods, and additional information specified using special attributes and tags Introspection

21 2007 Adobe Systems Incorporated. All Rights Reserved. 21  Extending Components Walkthrough 5

22 2007 Adobe Systems Incorporated. All Rights Reserved. 22  The access attribute of the tag determines how and where a method can be invoked  Method access can also be restricted based on the role of the user that is logged in  Use the tag to establish the roles Component Access Control

23 2007 Adobe Systems Incorporated. All Rights Reserved. 23  Private This function can only be called by other functions within the same component and any components that extend the component in which this function is defined Access Types and Description  Package This function can be called by any other component within the same directory in addition to the conditions for access=”private”  Public This function can be called by any ColdFusion page or component method located on the same server as this function  Remote This function can be called by any ColdFusion page or component method located on any server, or by any client through a URL, form submission, Flash Remoting or web service

24 2007 Adobe Systems Incorporated. All Rights Reserved. 24  Experimenting with Access Control Walkthrough 6

25 2007 Adobe Systems Incorporated. All Rights Reserved. 25  CFCs framework force developers to work in a more systematic way  Code inside a CFC is generally easy to follow and troubleshoot  Components help developers establish advanced development techniques by allowing for a higher degree of reuse, encapsulation, and security  Components can persist by placing them in the session or application scope  Some of the object-oriented features of CFCs include encapsulation, inheritance, and introspection  Component access can be restricted by using the access and roles attributes of the tag Summary

26 2007 Adobe Systems Incorporated. All Rights Reserved. 26  Questions  Thank you for attending this session Questions and Answers


Download ppt "2007 Adobe Systems Incorporated. All Rights Reserved. 1 Glenda Vigoreaux Adobe Certified Instructor roundpeg, Inc. Component Development."

Similar presentations


Ads by Google