Let's start with a simple class that will build your application's UI - the Page class.
- Create a subdirectory in your class library named page
- Create a file named class.cfm in that directory. This is the class definition file
- Place the following code in the class definition file
<cfscript>
stClassDef = structNew();
</cfscript>
- Now create a file named constructor.cfm and save it to this directory as well. The constructor method
is what will define all of your class' properties. For instance, each of our Web pages must have a title and
a background color, so let's create some properties for those by putting this code in the file.
<cfscript>
self.title = "cfObjects Samples";
self.bgcolor = "white";
</cfscript>
Here we defined that, by default, each page's title will be "cfObjects Samples" and the background color will be white.
We have now defined the class. This alone doesn't do much. We simply have a few properties for it. Now we need to
make some methods for the class - code that actually does something.
Move to Step 8 -->
|