Critter’s Code

This is a picture of a bridge and a city. I like bridges and cities. They make me smile.

Archive for the ‘ColdFusion’ Category

Dec-16-2009

Case sensitive keys in ColdFusion structures

I know this is old news, but this one bit me last night.

I needed to loop over a structure and return the keys and values in a case-sensitive xml format. Creating my structure like this:

1
2
3
4
5
<cfscript>
qHolder = structNew();
qHolder.userName = "Critter";
qHolder.firstName = "Critter";
</cfscript>

was returning the keys in all caps. (USERNAME, FIRSTNAME)

I had forgotten that if you need to preserve the case of the keys you need to create them like this:

1
2
3
4
5
<cfscript>
qHolder = structNew();
qHolder["userName"] = "Critter";
qHolder["firstName"] = "Critter";
</cfscript>

That will result in (userName, firstName). You can reference them with dot notation and the case will be preserved, so long as they are created using the [""] format.

As you were.

VN:F [1.9.1_1087]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.1_1087]
Rating: 0 (from 0 votes)
Posted under ColdFusion, Samples
Nov-3-2009

I rake leaves and do other stuff

I am a good great raker. I can rake leaves into pretty piles. I can rake leaves into pretty piles and then pickup said piles. I can rake leaves into pretty piles and then mulch said piles.

I am a great raker. If you need a great raker, well, I can travel, but it would be best to keep that local to Cary, NC. I have great kids, too. I can travel, but not relocate (telecommute… not available with raking)

I am a good great awesome hawesome coder. I love what I do. I absolutely LOVE working with ColdFusion/Flex/AIR, and on top of that… I am pretty damned good at it too.

I am a hawesome coder. If you need a hawesome coder, well, I can travel, but it would be best to keep that local to Cary, NC. I have hawesome kids, too. I can travel, but not relocate (telecommute… is available with coding)

I’m available for either. Actually, I am available for anything, and you can bet whatever it is, I’ll be pretty damned good at it. (if not I shall google my way through it!)


VN:F [1.9.1_1087]
Rating: 5.2/10 (5 votes cast)
VN:F [1.9.1_1087]
Rating: 0 (from 0 votes)
Posted under AIR, ColdFusion, Flex
Sep-8-2009

Bring Back the Bolt — CFinNC!!


VN:F [1.9.1_1087]
Rating: 8.6/10 (8 votes cast)
VN:F [1.9.1_1087]
Rating: +5 (from 5 votes)
Posted under ColdFusion, Presentations, User Group
Aug-13-2009

Ctz-Prowl updated

I made a couple of updates to the files. I added the attributes for proxyservers and proxyport. I also separated out the two examples so they are easier to use.

I’ve updated the zip file on ctzProwl.RiaForge.


VN:F [1.9.1_1087]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.1_1087]
Rating: 0 (from 0 votes)
Posted under CF9, ColdFusion, CtzProwl, Projects
Aug-11-2009

Push notifications on your iPhone via ColdFusion

There’s an app you can purchase in Itunes App Store that will allow you to send push notifications to your Iphone. The iphone application is called “Prowl: Growl Client” You can download a plugin that integrates with Growl on the MAC (and I believe windows too) allowing you to receive copies of growl notices from your computer to your phone.

While this is all fine and dandy. Prowl also exposes an API, which allows for 1,000 notifications sent per hour per IP. The API allows for easy integration and access via ColdFusion. The possibilities of what this could be used for are endless.

I’ve created a CFC that will allow you to easily send notifications to your iphone via the Prowl servers. Actually… I’ve created two CFCs. One for ColdFusion v9.0 using (scripting FTW!1!) and a version of the CFC that uses tags.

Set your account variables and create your object:

1
2
3
4
apikey = "ei4irkfkddkdkdkdke3ie9r9r9";
providerkey = "";
callto = "<a class="linkification-ext" title="Linkification: https://prowl.weks.net/publicapi/" href="https://prowl.weks.net/publicapi/">https://prowl.weks.net/publicapi/</a>";
appname = "Critter's Code'";

// connect to the prowl cfc //
p = createObject(“component”,”ctzprowl”).init(_apikey=apikey, _callto=callto, _providerkey=providerkey, _appname=appname);

and our calls to the service:

1
2
// verify account (it does count against your 1,0000 requests per hour)
x = p.verify();

if(x.complete and x.code eq 200)
{
// send notification to devices registered to our account. //
y = p.add(priority=’0′,event=’CF9′,description=”I’m in your phone via CF9′”);
}
// dump x (our verification call)
writedump(var=x,label=’Verification results’);

if(isDefined(“y”))
{
writeoutput(‘
‘);
writedump(var=y,label=’Add Notification results’);
}

Below is a screen of the dumps:

and the notification on my phone:

Basically.. for $2.99 you can program your server to send you notifications based on whatever..

I just need to finish packing a few things up with it.. and I’ll throw it up on RiaForge.

UPDATE:

I’ve uploaded the code to http://ctzprowl.riaforge.org

Itunes Link
Prowl Website (signup and generate API key)


VN:F [1.9.1_1087]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.1_1087]
Rating: 0 (from 0 votes)
Posted under CF9, ColdFusion, CtzProwl, Iphone, Projects
Jun-29-2008

Old School ColdFusion – The bolt has been inked!

This has been on my ‘todo’ list for ages. I finally got around to getting it inked this evening.

The best ColdFusion logo of them all!

Old School ColdFusion Logo Tattoo

There was also a really cool article in the L.A. Times about my Seesmic tattoo.

VN:F [1.9.1_1087]
Rating: 10.0/10 (1 vote cast)
VN:F [1.9.1_1087]
Rating: +1 (from 1 vote)
Posted under ColdFusion, Seesmic, Social Media, Stuff
Jan-6-2008

Using ColdFusion.navigate() from within a cfgrid.

I had what seemed like a simple task. Load a query into an html cfgid. Users could then click on a row (record) and be taken to an edit/update page.

Piece of cake. I have done this many times before. Unfortunately, this was my first time attempting it with ColdFusion 8 and all it’s ajaxy goodness. CFGRIDCOLUMN has an ‘href’ attribute, but I was not able to fire off javascript from it, it would only execute regular links. I wanted my edit screen to open up below the grid in a CFDIV.

After much googling and mucking around, I was able to piece together the following. Which adds a click event to the cell.

   1:  addLinksforaTasks = function()
   2:  {
   3:      gTask = ColdFusion.Grid.getGridObject('agrid_tasks');
   4:      cm = gTask.getColumnModel();
   5:      gTask.on('cellclick',function(grid,rowIndex,columnIndex,e)
   6:      {
   7:      var unitID = ColdFusion.getElementValue('agrid_tasks','taskform','taskid');
   8:      ColdFusion.navigate('atasks.cfm?action=edit&taskid='+unitID,'taskedit');
   9:       }
  10:      )
  11:  }

The hardest part to figure out was how to get the id field value (in this case taskid).  It is such a simple thing that I was sure is used constantly, but I could not find much help on the web. Here is the function explained:  ColdFusion.getElementValue(‘grid_name’,'form_name’,'columnid’). That gave me the taksid of the selected row in the grid.

To execute the function when the grid loads you need to add

<cfset ajaxOnLoad(‘addLinksforaTasks’)> to the page containing the grid.

One other thing to note, if you are loading a grid into a CFDIV, you need to put all helper functions on the parent page. They do not seem to execute correctly if they are included on the page loaded into the CFDIV.

Anyway… hope that can help someone…

VN:F [1.9.1_1087]
Rating: 9.0/10 (1 vote cast)
VN:F [1.9.1_1087]
Rating: +1 (from 1 vote)
Posted under Ajax, ColdFusion, Samples