1 / 15

Cold Fusion Tutorial

Cold Fusion Tutorial. Mohammad Shamma SIMS 213 Spring 1999. 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.

adolfo
Download Presentation

Cold Fusion Tutorial

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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. <cfquery name=“student_list” datasource=“student_db”> SELECT studentID, studentName FROM students <cfquery> The required attributes for <cfquery> are “name” and “datasource.” “Name” refers to an arbitrary name so that you can refer to this query in <cfoutput> 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 (cont’d) • Next, the <cfoutput> tag is required to display the output of a particular <cfquery>. <cfquery name=“student_list” datasource=“student_db”> SELECT studentID, studentName FROM students </cfquery> <cfoutput query=“student_list”> #studentID# -- #studentName# </cfoutput> Although the <cfquery> tags do not have to be placed within the <HTML> </HTML> tags, the <cfoutput> must be placed within these tags.

  7. CFML • The following output will be displayed with whatever HTML formatting is inserted inside the <cfoutput> </cfoutput> 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: <cfoutput query=“student_list”> <B> #studentID#</B> -- #studentName# </cfoutput> The <B></B> 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. <cfquery name=“student_list” datasource=“student_db”> SELECT studentID, studentName FROM students </cfquery> <HTML> <HEAD> <TITLE>CF Query example</TITLE> </HEAD> <BODY> <cfoutput query=“student_list”> #studentID# -- #studentName# </cfoutput> </BODY> </HTML>

  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. <input type=“text” name=“studentID” maxlength=“10”> <input type=“text” name=“studentName” maxlength=“25”> *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. <FORM ACTION=“addStudent.cfm” method=“POST”> <input type=“text” name=“studentID” maxlength=“10”> <input type=“text” name=“studentName” maxlength=“25”> <input type=“submit” name=“submit” value=“Insert Student”>

  11. Inserting data from a form. • The tag <CFINSERT> 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: <cfinsert datasource=“student_db” tablename=“students”> *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)

More Related