O'Reilly logo

Railo 3 Beginner’s Guide by Mark Drew

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - creating the Employee component

To define an object in CFML, you need to create a file with the extension .cfc, let's create the file Employee.cfc and put the following code inside it:

<cfcomponent name="Employee">
...
</cfcomponent>

Now that we have created a basic Employee component, we can call it from another CFML, .cfm template in a number of ways, firstly with the <cfobject> tag:

<cfobject component="Employee" name="myEmployee">
<cfdump eval=myEmployee>

Another way is to use the CreateObject() function:

<cfset myEmployee = CreateObject("component", "Employee")>
<cfdump eval=myEmployee>

You can also use the "new" keyword to create your object:

<cfset myEmployee = new Employee()>
<cfdump eval=myEmployee>

All of the methods ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required