adobe (macromedia) coldfusion mx

30
© KM 2009 the University of Greenwich 1 Coldfusion Adobe (Macromedia) ColdFusion MX Internet enterprise technologies made easy

Upload: lynton

Post on 20-Jan-2016

88 views

Category:

Documents


0 download

DESCRIPTION

Adobe (Macromedia) ColdFusion MX. Internet enterprise technologies made easy. History. Version 1 of ColdFusion released in 1995, by Allaire Corporation the first database driven web technology Rapidly acquired by Macromedia developed up to MX7 Current Version: Adobe ColdFusion 8 - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 1

Coldfusion

Adobe (Macromedia) ColdFusion MX

Internet enterprise technologies made easy

Page 2: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 2

Coldfusion

History

• Version 1 of ColdFusion released in 1995, by Allaire Corporation• the first database driven web technology

• Rapidly acquired by Macromedia• developed up to MX7

• Current Version: Adobe ColdFusion 8• rather different to ColdFusion 5• integration with J2EE since MX7

Page 3: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 3

Coldfusion

Claims:• Server-side scripting environment that enables

the rapid development of a web site• much less code than an equivalent ASP, JSP, or PHP

application

• More 'powerful' than competing languages.• Scripts are compiled into Java classes executed

by an embedded version of JRun• Macromedia’s powerful J2EE server

• see also Macromedia Flex

• Integrates many different Internet technologies• XML, Web services, and Java.

Page 4: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 4

Coldfusion

Extensible

• Java objects• standalone packages of code written in the Java language

• Custom tags written in C++ or Java• pieces of code to be used only with ColdFusion, written in either C++ or Java

• Java Server Page (JSP) tag libraries• originally built for use within JSP systems

• Java Server Pages• the JSP equivalent of ColdFusion templates

• Flash Remoting• enables ColdFusion to easily communicate with Flash movies

• Web services• used by other application servers, including non-ColdFusion servers

• COM (Component Object Model) objects• software objects that can communicate with one another on the Windows platform

• CORBA (Common Object Request Broker Architecture) objects• communicate with one another over networks and between platforms

• Operating system (Windows, Unix, etc)• through scripts (batch files) and executables

The ColdFusion Mark-up language can interface with many different technologies:

Page 5: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 5

Coldfusion

Flash Remoting• Links a Flash movie with ColdFusion• Flash authoring environment turned into a true

client-application development environment• designed to work directly with ColdFusion• asynchonous partial page updates

• Flash applications can communicate with ColdFusion by using an efficient binary format• AMF (Action Message Format)• requires only a fraction of the bandwidth taken up by

XML based data exchanges

Page 6: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 6

Coldfusion

XML + Web Services

• WDDX – Web Distributed Data eXchange• XML solution developed for ColdFusion

• A Web service provides a platform-independent software component to remote systems• using SOAP transports

• Any application server is capable of using web services created with ColdFusion• simply set the Access attribute of a ColdFusion

component function to Remote

Page 7: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 7

Coldfusion

Security

• Application• CFLOGIN integrates directly with J2EE security

• Sandbox• Can restrict the code in one directory from accessing specific

tags and datasources

• Locking• Application can lock shared memory scopes to prevent race

conditions, where one piece of code may interfere with another that is also trying to access the same data in shared memory.

Page 8: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 8

Coldfusion

JSP

• ColdFusion MX onwards is built on top of the same platform that runs JSP• JSP pages can be included in your

application, and you can share variables between ColdFusion and JSP

• Exception Handling• catch and throw native Java exceptions from

ColdFusion code

Page 9: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 9

Coldfusion

More GoodStuff• Graphs and charts

• loads of chart types, area, pyramid, scatter, 3D, etc.• PNG or Shockwave output

• Regular expressions• as good as anything in Perl

• IDE• loads of support in Dreamweaver

• Integration across the Adobe product suite• including FLEX

• Debugging• CFTRACE used to watch variables and/or trace execution time.• CFDUMP and CFLOG used to produced detailed log

Page 10: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 10

Coldfusion

(X)HTML Tag Based Syntax<cfquery name="GetCompanies"

datasource="MyDatabase"> SELECT

CompanyID, CompanyName

FROM Company

</cfquery><table>

<cfoutput query="GetCompanies"><tr>

<td>#CompanyID#</td><td>#CompanyName#</td>

</tr></cfoutput>

</table>

Page 11: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 11

Coldfusion

Tags• Empty tags:

<cfset bgColor = "FFCCAA"/>

or <cfset bgColor = "FFCCAA">

can be used.

• Paired tags:e.g.

<cfloop from="1" to="10" index="i"> ... </cfloop>

Page 12: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 12

Coldfusion

Use of the #

• The # sign is used to indicate ColdFusion variables or functions• inside ColdFusion tag pairs

<cfoutput> Today's date is #DateFormat(Now())# </cfoutput>

Page 13: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 13

Coldfusion

Variables & Conditionals

e.g.

#myVar#

#Val(1 + 1)#

<cfset aVar = ArrayNew(1)>

<cfif aVar[1] EQ "A">

First letter is an 'A'<br />

</cfif>

dimensions of the array

Page 14: Adobe (Macromedia) ColdFusion MX

Coldfusion

Operators• Basic operators, +, -, /, *• Sign operators, +, -• Modulo division, MOD• Integer division, \• Exponent operator, ^• Equality, IS, EQ, EQUAL• Inequality, IS NOT, NEQ, NOT EQUAL• Greater than, GT• Less than, LT• Greater than or equal to, GTE or GE• Less than or equal to, LTE or LE• CONTAINS

• note:"ColdFusion" CONTAINS "Cold" returns TRUE• DOES NOT CONTAIN• Boolean operators, NOT, AND, OR, XOR, EQV, IMP• Concatenation, &• Assignment operator, =

• note: only valid within cfset tag e.g. <cfset aVar = anotherVar + 1>

Page 15: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 15

Coldfusion

<cfoutput><cfset myName = "bob"><cfoutput>

<body bgcolor="FFCCAA">My name is #myName#.

</body></cfoutput>

<cfset myName = "bob"><cfoutput>

<body bgcolor="#FFCCAA">My name is #myName#.

</body></cfoutput>

<cfset bgColor = "FFCCAA"><cfset myName = "Bob"><cfoutput>

<body bgcolor="###bgColor#">My name is #myName#.

</body></cfoutput>

This produces a compiler error

Why?

Page 16: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 16

Coldfusion

Loops

<cfloop from="1" to="10" index="i">

<cfoutput>

#i#<br>

</cfoutput>

</cfloop>

Page 17: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 17

Coldfusion

Conditional Loops<cfset foo = TRUE><cfloop condition="foo EQ TRUE">

<cfset bar = RandRange(1, 10) /><cfoutput>#bar#, </cfoutput><cfif bar EQ 10>

<cfset foo = FALSE></cfif>

</cfloop>

Page 18: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 18

Coldfusion

Custom Tags• today.cfm contains: <cfswitch expression="#Attributes.Format#">

<cfcase value="Long"><cfset FormatMask = "dddddd, d mmm yyyy">

</cfcase><cfcase value="American">

<cfset FormatMask = "mm/dd/yyyy"></cfcase><cfcase value="European">

<cfset FormatMask = "dd/mm/yyyy"></cfcase><cfdefaultcase>

<cfset FormatMask = "mm/dd/yyyy"></cfdefaultcase>

</cfswitch> <cfoutput>#DateFormat(Now(), FormatMask)#</cfoutput>

• customTag.cfm contains: <cf_today Format="Long">

OUTPUT:Sunday, 14 Mar 2004

Page 19: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 19

Coldfusion

SQL• ColdFusion provides tags to execute SQL commands.

• and handle the results

• DB connectivity implements ODBC and JDBC• No connection strings

• requires a DSN configuration on the server• use ColdFusion server administration page http://localhost:8100/CFIDE/administrator.index.cfm

<cfquery name="GetEmployees" datasource="CFMXdbex">SELECT

SSN,FirstName,LastName,Salary

FROMEmployee

ORDER BY SSN</cfquery>

Page 20: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 20

Coldfusion

Client-Side Validation• <cfinput> can validate:

• date: A date in the standard U.S. format mm/dd/yyyy.• eurodate: A date in the standard European format dd/mm/yyyy.• time: A valid time in the format hh:mm:ss.• float: A floating-point number.• integer: A whole number.• telephone: A valid U.S. telephone number in the format ###-###-

####, where the hyphens can be replaced with spaces, and the first digits of the first and second group cannot be zero.

• zipcode: A valid U.S. zip code, either five or nine digits in the format #####-####, where the hyphen can be replaced with a space.

• creditcard: Strips all blanks and dashes from the card number and uses the standard mod 10 algorithm to validate the card number.

• social_security_number: A valid social security number in the format ###-##-####, where the hyphens can be replaced by spaces.

• regular_expression: If the other possible values don’t fit your need, you can give your own validation pattern in the form of a JavaScript regular expression.

Page 21: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 21

Coldfusion

Sliders<cfform>

<cfslider name="Salary" label="Salary:&nbsp;%value%" range="0, 100000"

scale="1000"height="50"

width="300"lookandfeel="METAL"/>

</cfform>

Page 22: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 22

Coldfusion

Trees<cfform><cftree name="EmployeeLocation" height="250" width="200"

lookandfeel="METAL"><cftreeitem value="1" display="North America"/><cftreeitem value="2" display="United States" parent="1"/><cftreeitem value="3" display="Canada" parent="1"/><cftreeitem value="4" display="Mexico" parent="1"/><cftreeitem value="5" display="Europe"/><cftreeitem value="6" display="Great Britain" parent="5"/><cftreeitem value="7" display="France" parent="5"/><cftreeitem value="8" display="Germany" parent="5"/><cftreeitem value="9" display="Spain" parent="5"/><cftreeitem value="10" display="Italy" parent="5"/><cftreeitem value="11" display="Austria" parent="5"/>

</cftree></cfform>

Page 23: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 23

Coldfusion

Grids<cfquery name="GetEmployees"

datasource="CFMXdbex">SELECT

SSN,FirstName,LastName,Salary

FROMEmployee

ORDER BY SSN</cfquery>

<cfgrid name="EmployeeData"height="200"width="400"query="GetEmployees"selectmode="BROWSE"autowidth="true">

</cfgrid>

Alternative selectmodes: single, row, column or edit

Page 24: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 24

Coldfusion

XML Handling• Using ColdFusion MX, an XML object is created using

the CFXML tag, as follows:

<cfxml variable="XmlObj"> <my-xml-tag> <my-child-tag /> </my-xml-tag> </cfxml>

• Range of XML handling features provided• DOM, XSLT, WDDX (Web Distributed Data eXchange)

• ColdFusion’s XML implementation does not validate against a DTD or XMLSchema document.• or does it?

Page 25: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 25

Coldfusion

Functions• More than 250 in-built functions.

• string-manipulation functions, array functions, structure functions, etc.

• User Defined Functions (UDFs)• <cfscript> encloses CFScript syntax

• very similar to JavaScript• limited capabilities

• <cffunction> encloses ColdFusion syntax• new to MX

• <cfinclude> implements script libraries

Page 26: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 26

Coldfusion

Application Framework• New to ColdFusionMX• Four basic components:

• application-level settings and functions• client, session, application and server scope variables • custom error handling • web server security integration

• Client, server, session, and application scope variables are stored in memory as structures• maintain data that must last beyond the scope of the

current page <cfapplication>• Protection for shared data structures <cflock>

Page 27: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 27

Coldfusion

State Preservation

Option:• In-built method using CFID and CFTOKEN pair

or• J2EE session management using jsessionid

<a href="page.cfm?#UCase(Session.URLToken)#">...</a>

J2EE requires JSESSIONID to be uppercase

Page 28: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 28

Coldfusion

Happy Customers

"UPS relies on ColdFusion for the hundreds of global intranet applications that enhance our business every day. The migration to ColdFusion MX was very smooth, and introduces benefits such as XML and ColdFusion Components to our development platform. Macromedia Flash Remoting is an area that interests us for future applications. We think that Macromedia Flash Player, combined with the power of the UPS server infrastructure, shows promise for a better user experience."

UPS

Page 29: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 29

Coldfusion

Industry Support• "By moving ColdFusion to the Java architecture, Macromedia is

helping to lead the industry trend of creating Web content on the Java platform. Now, an even broader developer base can take advantage of industry standard J2EE application servers. ColdFusion has a proven track record as an easy-to-use web development environment, and we welcome ColdFusion to the family of Java-compatible development tools."

Sun Microsystems

• "Many of our customers are already using ColdFusion as an environment for rapid application development. Macromedia's strategy to move ColdFusion to a Java architecture will make it possible for those customers to deploy their applications on IBM WebSphere Application Server and combine the ease of use of ColdFusion with the flexibility, extensibility, and robustness of the WebSphere software platform."

IBM

Page 30: Adobe (Macromedia) ColdFusion MX

© KM 2009 the University of Greenwich 30

Coldfusion

Conclusions• ColdFusion is not just HTML++

• Leverage the power of J2EE• enterprise strength environment

• Separation of concerns• n-tier architectures

• Integration with Macromedia product suite• power and beauty and productivity

• Not cheap• not an issue for the big players