The basic data object concept
Now we create the function for assigning the encapsulated variables of the object when it is created. We are now ready to write the next version of the calling page. We are only going to change two things on that page. We will change the line where we were creating a second recordset to a call to the method for performing the assigning of the internal variable values in the object. Then we will change our content section of the code to use the object getters to pull the encapsulated variable values. The highlighted rows are the ones changed.
<!--- Example: 2_6.cfm --->
<!--- Processing --->
<cfparam name="url.id" default="0">
<cfscript>
objProduct = createObject("component","product_2").init();
rsProducts = objProduct.getRecordset();
objProduct.load(url.id);
</cfscript>
<!--- Content --->
<ul><cfoutput query="rsProducts">
<li><a href="?id=#rsProducts.id#">#rsProducts.name#</a></li>...