header parallax image
uncoditional

code liberated

  • Home
  • Pete
  • Home
  • Pete
Uncategorized

CFScript Components and OO notes

June 12, 2015Peter Lombardo3768 views

Let’s start with a few notes and gotcha’s:

  • the attribute: accessors=”true” in combination with the property names, takes away any need for setters or getters.
  • Catch is done outside of the Try block. so try {} catch(any e) {}
  • Pete Freitag’s Cheat Sheet for loops and such is very helpful.
  • thanks the accessors attr) allows you to use the just the name of the bean. So…
  • property type="full.path.name.serviceBeanName" name="serviceBeanName" getter="true" setter="true";

    Thuscan then be called as simply serviceBeanName…[my function name]

  • Query’s look a little different:
    myQry = new Query();
    myQry.setDatasource("myDSName");
    myQry.setSQL("select top 10 * from myTable");
    writedump(myQry.execute().getResult());

    NOTE: can’t get a recordcount using getResult() from anything but a select statement. Instead use

    myQry.execute().getPrefix().recordCount
  • Gotcha Alert! There’s a little trick to getting a where-in clause to work.  See here for original post, but also spread the word.
    myQry.setSQL("select * from myTablewhere myID in (:idList)");
    offeringsQry.addParam(name="idList", value="1,2,3", 
    cfsqltype="cf_sql_integer", list="true");
    
    

    The key is to use the LIST parameter.


BEAN
This is your new bean. say hello! no getters. no setters. That’s taken care of by using properties, and the @setters “true” syntax at the top. Note that all that syntax at the top is VERY specific. spaces, not tabs. no commas or semicolons.

  • not even the name of the bean. that’s implicit in the name of the file.
  • component attributes don’t use commas and come before curly braces
component
output="false"
hint="I am the bean of the blah objects."
accessors="true"
{
property type="numeric" name="blahID" default="" getter="true" setter="true";
property type="string" name="foo" default="" getter="true" setter="true";

} 

DAO and GATWAY
Now for your DAO or Gateway. **note** these two need INIT functions to set dsn

component
output="false"
hint="sets objects in DB."
accessors="true"
extends = "tools.mybasetools"
{
property type="string" name="DSN" getter="true" setter="true";</pre>

public full.path.name.of.datatype.bean function init(required string DSN){
variables.dsn = arguments.dsn;
return this;
}
// public and private functions below... 
CFMLCFScriptMach-II
  • tweet
previous story

Extracting Header rows from .cfmail file

next story

welcome to unCODitional (sic)

Peter Lombardo

Peter Lombardo

Web developer too long.

you might also like

Simple Diagram of MVC/Mach-II

October 18, 2012

CFML-MachII and AJAX architecture

October 18, 2012

real Chrome developer features

October 8, 2014

Leave a Response Cancel reply

You must be logged in to post a comment.

about me

uncoditional

Pete Lombardo

I like people and coding. Both change. Twenty years of full-stack development. I live in Maryland.

Recent Posts

  •   lives on!
    									
  • Cannot find module ‘…/…’ or its corresponding type declarations.
  • *ngIf – use parentheses
  • Angular component code block execution order
  • material dialog- how to get response data .subscribe()

Recent Comments

    Archives

    • June 2022
    • March 2022
    • June 2020
    • June 2019
    • November 2017
    • October 2017
    • September 2017
    • August 2017
    • June 2017
    • June 2015
    • May 2015
    • April 2015
    • October 2014
    • September 2014
    • July 2014
    • June 2014
    • May 2013
    • February 2013
    • January 2013
    • November 2012
    • October 2012

    Categories

    • angular
    • AWS
    • before the code
    • Browser Support
    • CFML & Mach-II
    • Chromebook
    • ckEditor
    • CloudSearch
    • ColdFusion
    • Java
    • javascript/typescript
    • JQuery and CSS
    • Languages
    • Life
    • material design
    • project
    • Projects
    • SNS
    • SQL
    • Tools
    • Uncategorized
    • unCODitional

    Meta

    • Log in
    • Entries feed
    • Comments feed
    • WordPress.org
    0
    Followers
    0
    Followers
    0
    Followers
    0
    Followers

    Follow @ Instagram

    Configuration error or no pictures...