Slides - Usc

horseheadssolidInternet and Web Development

Nov 10, 2013 (3 years and 7 months ago)

59 views



ITP300
Week 4
Introduction to ColdFusion (CF)


Lecture Topics and Goals

Topics:

Setting up CF

Creating data sources in CF

CFOUTPUT, CFSET, formatting dates and CGI
variables

Goals:

Be able to setup a CF testing server and map an
Access as a data source

Be able to format dates and variables in ColdFusion


Questions

Homework?

SQL?

Joins?


Installing ColdFusion

Development server

Class server


What is ColdFusion (CF)?

Used to create dynamic websites

Server side programming language

Supports conditional logic, looping, and data-re-
use

End-result to client (web browser) is always
HTML

Propriety technology of Adobe


How a ColdFusion Server Works
End-user
(web browser)
Client request
IIS
(web server)
ColdFusion (CF) Server
(script server)
HTML file returned
IIS sends CF
code to CF
server
CF server
returns HTML
only


Parts of ColdFusion
1)
ColdFusion server
2)
ColdFusion administrator
3)
ColdFusion developer web server
4)
ColdFusion code


CF on the Class Server

Name files
something
.cfm

Must be inside web root to run:

C:/itp300/username
/


Coldfusion Markup Language
(CFML)

Ultimate goal: output HTML

CFML is mostly CF Tags

Perform calculations

Make database requests

Send e-mails

Etc

CF pages contain both HTML and CFML


CFML Syntax

Tags and functions

Tag syntax looks like HTML:

<CFTAGNAME></CFTAGNAME>

Function syntax looks like Javascript:
Now()


CFOUTPUT and CFSET

CFSET sets a value to a variable

Example: <cfset Name = “Justin”>

Surround variables with # signs

CFOUTPUT outputs variable contents

Wrap around any combination of text, HTML, CF
tags, CF logic and CF variables

Example:
<cfoutput>#Name#</cfoutput>
outputs “Justin”


Demo

A simple ColdFusion page

Create a file called index.cfm in the wwwroot
folder


CGI Variables

Stores information about the client connecting
to the web page

Different values for each person connecting to
the site

Example:

#CGI.remote_addr#

#CGI.http_user_agent#

Demo


Date and Time

Function Now() returns current server time

Example:
<cfoutput>#Now()#</cfoutput>
returns {ts '2006-09-13 20:52:50'}

Not time on client, time on CF server


Date and Time continued

Function DateFormat() converts a date passed
in to a more human readable format

Syntax:
DateFormat(
thedate
,
dateformat
)

Example:
<cfoutput>#DateFormat(Now(),'D MMMM,
YYYY')#</cfoutput>
returns 13 September 2005

Demo


Date and Time Code Sample
<cfoutput>
#DateFormat(Now(),'D MMMM, YYYY')#<br />
#DateFormat("Feb. 5, 2001")#<br />
#DateFormat("2/5/2001", "mm-dd-yyyy")#<br />
#TimeFormat(Now(), 'HH:mm')#<br />
#TimeFormat(Now(), 'hh:mm:ss t')#<br />
</cfoutput>


Coldfusion Resources

Getting started with CF:
http://www.adobe.com/devnet/coldfusion/getting_started.html

Coldfusion tag reference:
http://livedocs.macromedia.com/coldfusion/7/htmldocs/part_cfm.htm

Coldfusion cook book:
http://www.coldfusioncookbook.com/

Setting up and using ColdFusion:
http://www-rcf.usc.edu/~emond/itp300/20063-itp300-setting-up-and-using-cf.pdf


Lab

Lab 1: Classpage

Due at the end of lab

Grader must check it before end of clas


Homework

Assignment 4: Class Database

Due February 6th, at 5 pm

Post to class server and email grader


End
http://www-rcf.usc.edu/~emond/itp300/
~
Justin Emond
ITP 300