Sie sind auf Seite 1von 13

Cold Fusion

CS-422
Cold Fusion
• Core Technologies
– Proprietary, tag based, embedded scripting language
– Javascript, Java
• Platforms
– NT, LINUX, Solaris
– Apache, Netscape/iPlanet, IIS
• Databases
– Access, MS SQL Server (NT W/2000 Only)
– Sybase, Oracle, DB2
– MySQL (requires MYODBC driver)
Cold Fusion Architecture
HTML
Web Server JavaScript

Java

ODBC
JDBC
ColdFusion Native
Database
Server
Cold Fusion
• How it works
– Web server receives request for .cfm file and passes the request to
the CF server. CF Server parses the file returning all non- CF tags
to the requesting browser and resolving the CF tags into their
resolved text/values
• Benefits
– Multi-platform
– Easy to learn
• tag based (looks like HTML, gives web community comfort that its
just some additional tags)
– much support available via the web, wide following in the web
community
• Problems
– OEM pricing (current price of $5K/server)
Cold Fusion Server
• Installs as either an NSAPI or ISAPI plug-in to your web server
• Web based administration client
– Data source definition (ODBC and Native for Oracle, Sybase and DB2)
– connection to a mail server via the CFMAIL tag
– provides state maintenance via client and session variabled (kept in
Registry or in database)
– Java and C++ interface for interfacing user defined tags
– interface for OLEDB
– Verity indexing interface for generation search collections
– task scheduler for running CF batch jobs
– advanced security features based on Netegrity SiteMinder
Cold Fusion Studio
• Desktop client used to develop and deploy Cold Fusion applications
– Text based editor, with built in CF help environment and text coloring for
CF tags
– connects to ColdFusion server via FTP or proprietary RDS (Remote
Development Server)
– live connection to all data sources defined on the CF server for easy table
browsing and debugging
– built in debugger
– allows check-in/check-out of files to facilitate group development

Alternatives to Studio for Development
• And FTP client or file share on to Web server’s document tree
– WS/FTP, Netscape, Hummingbird, HomeSite
• A text editor
– Notepad, Wordpad, EMACS
• A good book on Cold Fusion ( Ben Forta’s are the best, he wrote the
language)
Cold Fusion Applications
• Collection of .cfm pages consisting of
– HTML
– Cold Fusion Tags (like HTML but all start with letters “CF”)
– SQL
– JavaScript
– ColdFusion function calls (a very rich library of function to aid in the
processing of user inputs and creation of dynamically generated HTML
and text
Application.cfm
• Each application may have an Application.cfm file
– this file is included ahead of each page of the application and is primarily
used for initialization
– whenever a .cfm page is requested from the web server, the CF server will
first load the Application.cfm file and then the requested file; processing
will start at the first line of the application

• Application.cfm is optional
<cfinclude>
• Syntax: <CFINCLUDE TEMPLATE=filename.cfm>
• Server includes the specified file in line with the current file; similar to
web server “server-side includes”
• allows modularization of CF code
• if many <cfinclude>s are used, each should start off with some debug
code to identify the file name so that in the event of a failure, you can
figure out which file the failure was in.

<html>
<head><title>Sample of CFINCLUDE</title></head>
<body>
<CFINCLUDE TEMPLATE=“mainfile.cfm”>
</body>
</html>
<CFSET>
• used to define Cold Fuaion variables
• SYNTAX: <CFSET variable_name=expression>

<CFSET months_in_year=12>
<CFSET this year = ArrayNew(months_in_year)>
<CFSET the_date=
#DateFormat(“#Now()#”)# & “ “ & #TimeFormat(“#Now()#”)>
<CFSET complex_expr = (23 MOD 12) * 3>
CFSET user_ip = CGI.REMOTE_ADR>
<CFOUTPUT>
• SYNTAX: <CFOUTPUT QUERY=“query_name” MAXROWS=“max_rows_of_output”
GROUP=“parameter” STARTROW=“starting_row”> ……..</CFOUTPUT>
– query_name:(optional) name of CFQUERY to associate with
– max_rows_of_output : (optional)
– group: (optional) for grouping to eliminate duplicates
– starting_row: (optional) the query row to start with
• whatever is created between <cfoutput> and </cfoutput> is sent to the requesting browser

Ex. without an associated query


<BR>Today is #DayOfWeekAsString(“#DayOfWeek(“#Now()#”)#”)#
<BR>Today is <CFOUTPUT #DayOfWeekAsString(“#DayOfWeek(“#Now()#”)#”)#</cfoutput>
<CFQUERY>
• used to pass a SQL query statement to a data source
• Syntax: <CFQUERY NAME=“Name_for_query_results”
DATASOURCE=“CF_datacource_name”>…..</cfquery>
– many other attributes, those shown are required

<CFQUERY NAME=“GetParks” DATASOURCE=“parks”>


SELECT PARKNAME , REGION , STATE FROM Parks ORDERBY ParkName , State
</CFQUERY>
<TABLE>
<CFOUTPUT QUERY=“GetParks”>
<TR><TD>#ParkName#</TD>
<TD>#Region#</TD>
<TD>#State#</TD></TR>
</CFOUTPUT>
</TABLE>

Das könnte Ihnen auch gefallen