cf101: welcome to coldfusion simon horwith cto, etrilogy ltd

27
CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd.

Upload: georgia-oliver

Post on 05-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd

CF101: Welcome to ColdFusion

Simon Horwith

CTO, Etrilogy Ltd.

Page 2: CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd

Who Am I?

• Macromedia Certified:InstructorAdvanced ColdFusion DeveloperFlash Developer

• Member Team Macromedia• CTO, Etrilogy Ltd. (London)• Private Consultant – Web/DB App Dev• Frequent CFUG and Conference Speaker• Monthly Contributor to CFDJ Magazine• Contributing Author of Several Books

Page 3: CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd

Who Are You?

• Web site developerLooking to add more interactivity to your

site

• Web application developer or development manager who’s heard of ColdFusionWondering how it works, how easy it is to

use, how scalable it is for enterprise apps

Page 4: CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd

What We’ll Cover

• We’ll show:How easy it is to use and how it works How CF can be used to add interactivity to

your siteThe basics of CF programming: no

previous CF experience requiredHow the features of CF make it an ideal

platform solution for meeting complex business requirements

Page 5: CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd

Topics

• Introduction to ColdFusion

• Code Basics

• Database Integration

• ColdFusion Features

• Q&A

Page 6: CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd

Introduction to ColdFusion

• ColdFusion is:A leading Server-Side Web Application

Development SystemThe leading rapid development platform

for the webVery easy to learn and to useOS platform independentA key part of Macromedia’s MX product

line

Page 7: CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd

Introduction to ColdFusion cont’d• On the web there are 2 classes of web

technologies: server-side and client-side

• Client-side technologies run in a users browser – Flash, JavaScript, Java Applets, etc.

• Server-side runs on a central server – ColdFusion, ASP, ASP.NET, Perl, PHP, etc.

Page 8: CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd

Introduction to ColdFusion cont’d• Static Web Architecture – user sends an HTTP

request to a web server which then returns HTML (along with any client-side technology code) back to the browser for parsing

• Dynamic Web Architecture – user sends an HTTP request for a dynamic page to a web server. The web server routes the request to the Application Server which parses the server-side technology instructions and sends the resulting text back to the browser for parsing.

Page 9: CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd

Introduction to ColdFusion cont’d• ColdFusion files have a .cfm extension• The web server hands any request for a .cfm

page to the ColdFusion server for processing• The ColdFusion server looks through the

contents of the page for instructions and ignores all other text (text, HTML, and other client-side technologies may be used in CF pages as the CF Server ignores them and they are sent back to the browser along with the dynamic page output)

• ColdFusion Instructions are written in CFML

Page 10: CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd

Code Basics

• ColdFusion pages are written in CFML – ColdFusion Mark-up Language

• CFML is:Like HTML- it is a tag based languageUsed to tell the ColdFusion server to

connect with a database, create a variable, etc.

Processed in place. HTML and CFML are often interwoven in order to mark-up the output generated by CF tags

Page 11: CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd

Code Basics cont’d

• CFML tags begin with the letters “CF”

• Two very common tags:<CFSET> creates a variable<CFOUTPUT> displays a variable

• Example:<CFSET firstName = “Simon”>

<CFOUTPUT> #Variables.firstname#</CFOUTPUT>

Page 12: CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd

Code Basics cont’d

• Variables in CF:Are case-insensitiveAre typelessExist for the duration of a request and are then

destroyedHave a prefix. A variable prefix tells ColdFusion

where this variable exists in memory. ColdFusion will search for a variable in many memory scopes if no prefix is specified. This impacts on performance and readability.

Page 13: CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd

Code Basics cont’d

• <CFOUTPUT>Has both an opening and closing tagTells ColdFusion to examine the text

between the opening and closing tag and to evaluate any variable or expression surrounded with hash marks (“#”)

Any non-CFML text inside <CFOUTPUT> is ignored, which

Page 14: CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd

Code Basics cont’d<cfset fname = “Simon”><cfset lname = “Horwith”><cfset fullname = variables.fname & “ “ & variables.lname><cfset email = [email protected]><cfoutput>Name: <b>#variables.fullname#</b><br>Email: <a href=“mailto:#variables.email#”>#variables.email#</a></cfoutput>

Would display:

Name: Simon HorwithEmail: [email protected]

Page 15: CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd

Code Basics cont’d

• CFML comments are used to comment code and to prevent code from being parsed

• Example:

<!--- this is a ColdFusion Comment --->

Page 16: CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd

Code Basics cont’d

• CFML not only has tags, but functions as well. There are over 70 tags and over 200 functions in the CFML language.

• A few types of functions:Date manipulation/formattingArray/structure manipulationString manipulationList manpulationMathematic operationsEtc.

Page 17: CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd

Code Basics cont’d

• Example of how to use functions to retrieve today’s date (now() function) and display it in “mm/dd/yy” format (dateformat() function)

<cfoutput>

<!--- display today’s date in mm/dd/yy format --->

#dateformat(now(),”mm/dd/yy”)#

</cfoutput>

Page 18: CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd

Database Integration

• CF can communicate with virtually any database, including:Microsoft SQL ServerSybaseOracleDB/2Informixand many more enterprise DBMS’s, as well as

desktop DBMS’s such as MS Access

Page 19: CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd

Database Integration cont’d• ColdFusion MX uses Java Database Connectivity

(JDBC) drivers to connect with databases

• JDBC drivers translate SQL (Structured Query Language) commands to native binary code that a database understands, pass that binary code to a datasource for execution, and return any returned resultset to the ColdFusion page that invoked it.

• A datasource is a “named connection” (alias) for a database – it stores the database name, location, server name, login and password, etc.

Page 20: CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd

Database Integration cont’d• ColdFusion passes SQL to a datasource using the

<CFQUERY> tag• <CFQUERY> should always have:

Name (assigns a name to the resultset and makes code more readable)

Datasource (the DataSource name that points at the database to pass the SQL to)

Example:<CFQUERY name=“qEmployees” datasource=“myDSN”>

SELECT firstname, lastnameFROM employeesORDER BY lastname

</CFQUERY>

Page 21: CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd

Database Integration cont’d

This code produces an ERROR!!

<CFQUERY name=“qEmployees” datasource=“myDSN”>

SELECT firstname, lastname

FROM employees

ORDER BY lastname

</CFQUERY>

<cfoutput>

#firstname# #lastname#

</cfoutput>

Page 22: CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd

Database Integration cont’d

This code displays only the first row from the recordset

<CFQUERY name=“qEmployees” datasource=“myDSN”>

SELECT firstname, lastname

FROM employees

ORDER BY lastname

</CFQUERY>

<cfoutput>

#qEmployees.firstname# #qEmployees.lastname#

</cfoutput>

Page 23: CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd

Database Integration cont’d

This code loops over each row from the recordset and displays it<CFQUERY name=“qEmployees” datasource=“myDSN”>

SELECT firstname, lastnameFROM employeesORDER BY lastname</CFQUERY><cfoutput query=“qEmployees”>#qEmployees.firstname# #qEmployees.lastname# <br></cfoutput>

Page 24: CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd

CF Features: Yes it can do all this… and SO much more!

• Tags and functions for creating, reading, renaming, moving, renaming, and deleting files and folders from the local file system

• Easy access to LDAP (lightweight directory access protocol) resources

• COM, DCOM, and CORBA support• Easy integration with existing Java Applications• HTTP functionality• Out of the box ease of establishing connections

with MANY RDBMS platforms• Built-in security framework

Page 25: CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd

CF Features cont’d• Advanced record-set functionality• Robust graphing and reporting functionality• Application architecture that supports persistent

memory scopes• Over 70 tags and 200 functions built-in to the easy

to use and learn CFML programming language• Custom Tags and User-Defined Functions• An object-oriented framework (ColdFusion

Components) that offers OOP features and a layer of abstraction between business logic and presentation

Page 26: CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd

CF Features cont’d

• Web services support for consumption and publication, ,including support for Java, .NET, and Flash Remoting Applications

• XML support• Web based Administrative interface• Platform independent – runs as a standalone

server or J2EE application on many platforms.

• Many online and printed resources• SO MUCH MORE!

Page 27: CF101: Welcome to ColdFusion Simon Horwith CTO, Etrilogy Ltd

Good Luck!

• And enjoy ColdFusion!

• Q & A time