Intro to Coldfusion - Southeast Missouri State University

horseheadssolidInternet and Web Development

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

84 views

Web Database
Development using
ColdFusion

Publishing Data on the Web

Creating Static Web Pages


The simplest way to publish data from
your database to a Web page is to
export the data as
static

HTML file.


This file presents a snapshots of your
data.


To refresh the data on the Web page,
you have to repeat the export
process.

The Procedure to export to
HTML

In the ACCESS Database window,


Select the object to export.


Choose Export from the File menu.

In the Save as type drop
-
down list,


Choose HTML Documents.

The exported file qradequery.htm can
be read by Web Browser.

Creating a Dynamic Active
Server Page


Generating a page dynamically


Creating it at the moment it is
requested by the user’s browser



Static Page


HTML documents that physically
resides on a server

What is ColdFusion?


Web application server


A programming language


A database front end


A database
-
to
-
Web gateway



It allows you take an existing database file
and serve it up via the Web without having
to create HTML files.

ColdFusion


Generates a page
dynamically

means to
create it Ion
-
the
-
fly (at the moment it is
requested by the user’s browsers.


The databases are uploaded to the
management server.


ColdFusion

Template File
with CFM
extension. It contains text and code
directing ColdFusion to Perform actions.

CF as a DB
-
to
-
Web
Gateway


It allows developers to link a DB to a
web site and display one (Dynamic
Page Generation).


It is also a Data Collection tool
<CFINSERT>.


Client Server Computing


Tag Processing


HTML (Hyper Text Markup
Language)Tag


<I> <B>


CFML (ColdFusion Markup
Language) Tag


<CFQUERY> <CFOUTPUT>


ColdFusion Application Server and
Web Server


run concurrently

A Coldfusion Template File
(CFM)


A Web page that contains text and
code directing ColdFusion to perform
an action or actions


Coldfusion is transparent to end
-
users.


Because it is a back
-
end application,
the average surfer won’t even know
you are using it.

Why ColdFusion?


Database
-
Driven Business Sites


Real
-
Time Web Presentation


can
put entire operation on
-
line in real time


Interfacing with intranets


E
-
Commerce Ready


Data (user input) Collection from the
Web, input it into a database on your
server


How CF works within the
C/S relationship


CF resides on the server computer,
running in conjunction with Web
server software.


It waits for a client to send a request
URL that has the .CFM extension (CF
template file.
http://management.semo.edu/sbeom/
day1/elvis1.cfm


Assignment: Creating a CFML
tag


To develop web based database application, we
create a script, which is plain
-
text file that contains
the coldfusion markup language (CFML).


The next slide show a simple example of a CFML
tag.


Use either notepad or wordpad and save as
ELVISbySBE.cfm on your computer . Of course,
replace “SBE” with your initials. Make sure that
your file must be saved with cfm extension.


All you need to do is typing exactly the same as
you see.

How CF works within the C/S
relationship (Tag Processing)


<CFQUERY NAME="MOVIES" DATASOURCE="elvis">



SELECT title, year, rating FROM movies


</CFQUERY>


<HTML>



<HEAD>




<TITLE> Elvis' Worst Movies</TITLE>



</HEAD>



<BODY>



<H1>Elvis' Worst Movies</H1>


<CFOUTPUT QUERY="movies">



<P>Movie Title: #title#</P>



<P>Date Released: #year#</P>



<P>My Rating: #rating#</P>


</CFOUTPUT>



</BODY>


</HTML>

Publish the first CFML tag


Now you need to publish to your
webpage (the index page) you
created.


Your index page should contain a
minimum your name and an
welcoming statement for visitors.


Hyperlink this cfml tag so that I can
visit your page for grading purpose.


For those who never used FrontPage
or SharePoint designer, here are the
links for you.


FrontPage


SharePoint Designer


Connecting DB to the Web
via the CF Template


CF Template can be hand
-
coded or
special program such as ColdFusion
Studio, Homesite, etc.


File extension .CFM


Organization


The Query


HTML Markup


The Output



CF Template


The Query

CFQUERY


The CFQUERY Tag

Syntax

<CFQUERY Name =“query_name)

DataSource=Database name without MDB ext.>

SQL Statements

</CFQUERY>



<CFQUERY

NAME="MOVIES" DATASOURCE="elvis">

SELECT title, year, rating FROM movies


</CFQUERY>



HTML Markup


The usual HTML tags define the
following


Page title


Header


Color of the page


The HTML File Structure


<HTML>


<HEAD>


</HEAD>



<BODY>



</BODY>

</HTML>



The Query Section

<HTML>



<HEAD>


</HEAD>



<BODY>



The CF Output Section



</BODY>

</HTML>



HTML Markup


<HTML>



<HEAD>




<TITLE> Elvis' Worst Movies</TITLE>



</HEAD>


<BODY>



<H1>Elvis' Worst Movies</H1>





<CFOUTPUT





The output




</CFOUTPUT>


</BODY>


</HTML>


The Output: CFOUTPUT


<CFOUTPUT QUERY="movies">



<P>Movie Title: #title#</P>



<P>Date Released: #year#</P>



<P>My Rating: #rating#</P>


</CFOUTPUT>



The output section lies between the
<CFOUTPUT>tags and contains
variables


A Variable is a symbol or a name that
holds a value. Variable=DB Attribute


Note the hash marks (#), Reference to
a variable(= attribute in the table
using)


Useful Tags for the Body
Section


<I></I> italicized text


<B></B> Bold text


<A HREF=XXXX> </A> for a
hypertext link to another file


<H#><H#> for headlines from H1 (the
larges) to H6 (the smallest)
Paragraph break


<Big><Big/> Large Type


<strong></strong> extra emphasis


<p></p> a paragraph break, a line
break, a blank line


<BR> for line break, but no blank line


<HR> for a rule (solid line) between
sections.


http://www.w3schools.com/tags/tag_p
re.asp

ColdFusion Functions


Real
-
time manipulators of data


Use of Functions


Trim extra characters


Case Conversion


Changing the display format of time,
currency, date, etc.


ColdFusion Functions


Functions Format

SomeFunction(SomeVariable)


Within CFOUTPUT Tag


#SomeFunction(SomeVariable)#


General Function Rules


Function Input


either a string or a
variable

ColdFusion Functions


<CFOUTPUT>

#
DollarFormat
(Variable)#

</CFOUTPUT>


Display and Formatting Functions


Display and formatting functions are
some of the most commonly used
functions.


It standardizes user’s form input



DollarFormat()


DollarFormat(number) or


DollarFormat(Variable)



#DollarFormat(123456)#


Produces the text $123,456.00


A $ sign


A comma for thousand


A decimal point



DateFormat()


#DateFormat(“Apr. 14, 2004”, “DD
MMMM YYYY)#


Produces 14 April 2004


#DateFormat(“Apr. 14, 2004”, “ MM/
DD/YY”)#


Produces 04/14/04


Assigment


Write a Template page (CFM file) that displays all scholarships
available at Southeast Missouri State University and publish it on your
web
-
site. Include scholarship name, amount with DollarFormat
Function, two other fields of your choice.



Write a Template page (CFM file) that displays all scholarships
available at Southeast Missouri State University and publish it on your
web
-
site. The amount of scholarship should be grater than 1000 and
should be “need
-
based”. Include scholarship name, amount with
DollarFormat Function, two other fields of your choice.


Access database can be downloaded from Dropbox., in order for you
to examine the fields, data types, of this database.


Other information: this database is already on the management
server. ColdFusion CFML tags need two essential information.


Database name:SCHOLARSHIPDB (you don’t need a file
extension such as mdb or accdb)


Table name: TBL_SCHOLARSHIP (you don’t need a file
extension)


Upload two CFM files to your web page and hyperlink them to your
index page.