Cold Fusion Tutorial - PowerPoint PPT Presentation

About This Presentation
Title:

Cold Fusion Tutorial

Description:

Cold Fusion Tutorial Brief overview of CF Three-tiered architecture Building CF queries Specifying CF query output Building CF data input forms Inserting data from ... – PowerPoint PPT presentation

Number of Views:122
Avg rating:3.0/5.0
Slides: 16
Provided by: Mohamme51
Category:
Tags: cold | data | fusion | tutorial

less

Transcript and Presenter's Notes

Title: Cold Fusion Tutorial


1
Cold Fusion Tutorial
  • Mohammad Shamma
  • SIMS 213 Spring 1999

2
Cold Fusion Tutorial
  • Brief overview of CF Three-tiered architecture
  • Building CF queries
  • Specifying CF query output
  • Building CF data input forms
  • Inserting data from a CF form
  • A sample CF database drill-down application

3
Cold Fusion Architecture
4
Cold Fusion Architecture
  • As shown in the previous slide, the Cold Fusion
    Application Server (CFAS) processes .cfm
    templates by parsing only CFML (Cold Fusion
    Markup Language) tags within the template.
  • CFML looks almost exactly like HTML which makes
    building .cfm templates easier for user who are
    familiar with HTML.

5
Intro to CFML
  • This is an example of CFML query that produces a
    student list.
  • ltcfquery namestudent_list datasourcestudent_d
    bgt
  • SELECT studentID, studentName
  • FROM students
  • ltcfquerygt
  • The required attributes for ltcfquerygt are name
    and datasource. Name refers to an arbitrary
    name so that you can refer to this query in
    ltcfoutputgt and datasource refers to the unique
    datasource name specified in the ODBC
    Administrator tool in Microsoft Windows. For
    further informaiton on ODBC please see FAQ at
    (http//www.roth.net/odbc/odbcfaq.htm).

6
CFML (contd)
  • Next, the ltcfoutputgt tag is required to display
    the output of a particular ltcfquerygt.
  • ltcfquery namestudent_list datasourcestudent_
    dbgt
  • SELECT studentID, studentName
  • FROM students
  • lt/cfquerygt
  • ltcfoutput querystudent_listgt
  • studentID -- studentName
  • lt/cfoutputgt
  • Although the ltcfquerygt tags do not have to be
    placed within the ltHTMLgt lt/HTMLgt tags, the
    ltcfoutputgt must be placed within these tags.

7
CFML
  • The following output will be displayed with
    whatever HTML formatting is inserted inside the
    ltcfoutputgt lt/cfoutputgt tags. So if we wanted to
    apply HTML formatting to one of the output fields
    in the previous example, we would do so like
    this
  • ltcfoutput querystudent_listgt
  • ltBgt studentIDlt/Bgt -- studentName
  • lt/cfoutputgt
  • The ltBgtlt/Bgt tags around the studentID output
    field will apply a Bold font style to that
    particular field.

8
What would this .cfm file look like?
Once finished the .cfm file would look like
this.
ltcfquery namestudent_list datasourcestudent_d
bgt SELECT studentID, studentName FROM
students lt/cfquerygt ltHTMLgt ltHEADgt ltTITLEgtCF
Query examplelt/TITLEgt lt/HEADgt ltBODYgt ltcfoutput
querystudent_listgt studentID --
studentName lt/cfoutputgt lt/BODYgt lt/HTMLgt
9
CF Data Input Forms
  • A typical way to build a CF based data input form
    is to create a typical HTML form and assign the
    appropriate field names as attributes within your
    form.
  • Ex.
  • ltinput typetext namestudentID
    maxlength10gt
  • ltinput typetext namestudentName
    maxlength25gt
  • Notice that the names of these two inputs
    correspond to the field names used in the
    previous example.

10
CF Data Input Forms
  • Next you need to specify the form action, which
    in this case is the page that will insert the
    data from the form into the student_db
    datasource.
  • ltFORM ACTIONaddStudent.cfm methodPOSTgt
  • ltinput typetext namestudentID
    maxlength10gt
  • ltinput typetext namestudentName
    maxlength25gt
  • ltinput typesubmit namesubmit valueInsert
    Studentgt

11
Inserting data from a form.
  • The tag ltCFINSERTgt is an easy way to insert data
    from a form into a database table. The following
    is an example of what would be placed at the top
    of the addStudent.cfm action template
  • ltcfinsert datasourcestudent_db
    tablenamestudentsgt
  • Note that we are using the same datasource and
    that that table to be updated is specified as
    well.

12
Sample CFML files
  • Along with these notes are a set of .cfm files
    that read and display simple data from a
    datasource, add data to that datasource and
    perform complex searches to drill-down into
    that datasource.
  • The datasource for these files is a Microsoft
    Access database file called (tutorial.mdb).

13
CFML Sample files
  • The file grade_report.cfm produces a list of
    students and their grades from particular
    courses.
  • The files addStudentGrade_EntryForm.cfm and
    addStudentgrade_EntryAction.cfm allow data to
    be inserted into the database.

14
CFML Sample files
  • Finally the last set of files allow you to build
    complex data drill-down applications to the
    database
  • studentsearch_Search.cfm
  • studentsearch_Result.cfm
  • studentsearch_Detail.cfm
  • studentsearch_AppendCriteria.cfm

15
More on Cold Fusion
  • If you want to know more about Cold Fusion
    (http//www.allaire.com)
  • Further documentation can be viewed from
    (http//www.allaire.com/Documents/cf4docs.cfm)
Write a Comment
User Comments (0)
About PowerShow.com