header parallax image
uncoditional

code liberated

  • Home
  • Pete
  • Home
  • Pete
Uncategorized

CFScript Components and OO notes

June 12, 2015Peter Lombardo2011 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…
  • [code language=”javascript”]property type="full.path.name.serviceBeanName" name="serviceBeanName" getter="true" setter="true";[/code]

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

  • Query’s look a little different:

    [code language=”javascript”]
    myQry = new Query();
    myQry.setDatasource("myDSName");
    myQry.setSQL("select top 10 * from myTable");
    writedump(myQry.execute().getResult());[/code]

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

    [code language=”javascript”]myQry.execute().getPrefix().recordCount[/code]

  • 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.

    [code language=”javascript”]myQry.setSQL("select * from myTablewhere myID in (:idList)");
    offeringsQry.addParam(name="idList", value="1,2,3",
    cfsqltype="cf_sql_integer", list="true");

    [/code]

    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

[code language=”javascript”]
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";

} [/code]


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

[code language=”javascript”]
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… [/code]

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 the fun of coding in its ever changing state. I've lived in Maryland since I was 2 months old. Its smells and sounds are like an old glove. But I look forward to coding and blogging wherever I wake up tomorrow. I've spent 20 years as a programmer and IT guy, but have never had more fun with this stuff than I do now.

Recent Posts

  • ChromeBook as Development Environment: YMMV
  • Once more into the cloud
  • AWS CloudSearch file/data upload using JDK – code sample
  • programming basics/refresher done right
  • cf – create crud from column names.sql

Recent Comments

    Archives

    • 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

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

    Meta

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

    Follow @ Instagram

    Configuration error or no pictures...