Skip to content

Instantly share code, notes, and snippets.

@learncfinaweek
learncfinaweek / gist:4121304
Created November 20, 2012 21:31
Mail - Hands On 22

In this hands on example, you are going to add email functionality to the contact form.

Tags Used: <cfmail>

Configure Mail Settings

Before you can send emails with ColdFusion, a mail server you want to use needs to be set. Configuring the mail server can be done in the ColdFusion Administrator.

If you do not have a mail server of your own, your localhost can act as a mail server. ColdFusion will act normally, but since there is no mail server set up on your localhost, emails will not arrive at their destination. Another option is to use the mail server of Gmail (a Gmail account is required for this). The settings for this mail server can be found at the end of this section.

@learncfinaweek
learncfinaweek / gist:4121293
Created November 20, 2012 21:29
ORM - Hands On 21

In this hands on, we are going to add categories to blog posts. The logic for this involves creating a linking entity to which both the blog post and category will be associated. This is an alternative method to using a many-to-many relationship.

Tags Used: <cfloop>, <cfset>

Functions Used: EntitySave, for,

@learncfinaweek
learncfinaweek / gist:4121288
Created November 20, 2012 21:29
ORM - Hands On 20

In this hands on example, you are going to update the front end of the web site to pull in the blog information you have entered through the admin.

Tags Used: <cfloop>, <cfoutput>, <cfparam>, <cfset>, <cfif>

Functions Used:

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

In this hands on example, you are going to add the list and create functionality in the Admin for the blog posts and categories.

Tags Used: <cfset>

Functions Used: EntityLoad, EntityNew, now

@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.
@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: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.

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:4121267
Created November 20, 2012 21:25
Application.cfc - Hands On 16