Skip to content

Instantly share code, notes, and snippets.

@learncfinaweek
learncfinaweek / gist:4121240
Created November 20, 2012 21:22
Code Reuse - Hands On 13

In this hands on, we are going to separate out the header and footer and put the code into separate files that will be included.

Tags Used: <cfinclude>, <cfparam>, <cfif>, <cfset>

  1. Create a folder called includes in the www folder.
@learncfinaweek
learncfinaweek / gist:4121245
Created November 20, 2012 21:23
Code Reuse - Hands On 14

In this hands on, we will create a custom tag that will handle the display of the header and footer.

Tags Used: <cfif>, <cfelse>, <cfset>, <cfimport>

  1. Create a folder called customTags in the /www/ folder.
@learncfinaweek
learncfinaweek / gist:4121250
Created November 20, 2012 21:23
Code Reuse - Hands On 14

In this hands on, we will create a custom tag that will handle the display of the header and footer.

Tags Used: <cfif>, <cfelse>, <cfset>, <cfimport>

  1. Create a folder called customTags in the /www/ folder.
@learncfinaweek
learncfinaweek / gist:4121259
Created November 20, 2012 21:24
Code Reuse - Hands On 15

In this hands on, let's create a component where we will place the convertStringToASCII function inside of a component and instantiate it.

Tags Used: <cfcomponent>, <cffunction>

Functions Used: createObject

@learncfinaweek
learncfinaweek / gist:4121263
Created November 20, 2012 21:25
Application.cfc

By now you've learned the basics of ColdFusion, script vs. tag syntax, scopes, how to deal with data, and even some code-reuse techniques. You're now able to write something useful, so it's time we introduce you to the Request Lifecycle.

You see, when someone requests a ColdFusion page, CF doesn't just start executing your code. There are several events that first take place, which you can be waiting for, and to which you can react. This is not strictly necessary, but you'll find that any complex application will eventually want to make use of some or all of these features, so it's best that you know about them. In order to react to these events, you need to have an Application.cfc file. ColdFusion has designated Application.cfc as a special component that it will automatically look for, and in which we can put our event listeners for request lifecycle events.

A Note on Terminolog
@learncfinaweek
learncfinaweek / gist:4121267
Created November 20, 2012 21:25
Application.cfc - Hands On 16

One could write a book specifically about Object Oriented Programming (OOP). This chapter is an OOP primer to get you started, but for a more in-depth explanation, check out Matt Gifford's Object Oriented Programming in ColdFusion.

What is OOP?

Object Oriented Programming is a set of concepts and techniques that make use of the "object" language construct, to write more reusable, maintainable, and organized code. Objects are implemented differently in every language; in ColdFusion, we have ColdFusion Components (CFCs). Using objects doesn't require OOP, and not every use of objects is OOP. They are simply the building blocks for writing OOP code.

When you write a lot of OOP code, you'll quickly find yourself writing repetitive code to wire together everything necessary to respond to a given request; if you take some time to write a single path through the code that analyzes the request and autom

@learncfinaweek
learncfinaweek / gist:4121271
Created November 20, 2012 21:26
OOP - Hands On 17

In this Hands On we are going to create an encapsulated cfc that holds error data.

Functions Used: ArrayAppend, ArrayLen

  1. Create a new file called errorBean in the /www/admin/cfc/ folder.
@learncfinaweek
learncfinaweek / gist:4121277
Created November 20, 2012 21:27
ORM - Intro to ORM

Introduction

Object-Relational Mapping (ORM) allows you to work with objects and have them saved to the database automatically. It can greatly simplify create-read-update-delete (CRUD) operations and make your code more object-oriented. Under the hood, ColdFusion uses the industry leading ORM framework called Hibernate.

Configuration

@learncfinaweek
learncfinaweek / gist:4121279
Created November 20, 2012 21:28
ORM - Hands On 18

In this hands on example, you are going to create the ORM entities for the Blog Section.

Functions Used: ormReload

  1. Open up the /www/Application.cfc file in your code editor.