jump to navigation

NOTE: The spam filter is being unusually aggressive. If you comment does not immediately appear, it has simply been placed in moderation and I will approve it as quickly as possible. Thank you for your patience.

"Murphy was an optimist!"

What kind programs do you write? July 27, 2007 8:08 am

Posted by Doug McCaughan in : ColdFusion, Daily Life, Programming, Technology
, add a comment

I often get asked, "Now, what do you do?" and when I try to explain it I get these blank stares and gapping mouths to which I pause then say, "I make web pages." Their eyes light, heads nod, and they declare, "OOooh!" Quickly followed by a subject change.

What do I really do? Right now I am writing an application that allows service providers to advertise their services. So someone seeking a service goes to the website and enters what they are looking for and the matching providers pop up. Sounds simple enough right? Well, if I do my job correctly it will appear amazingly simple to the end user. The behind the scenes programming complexity is awe inspiring. As a minor example, the administrator has to take requests from service providers to be apart of the website. Then the administrator has to create the service provider profile which implies an administrative website that only the staff can access (roles based security). A profile! That’s simple right? Just a database table with all the descriptions of the provider and services offered right? Not really. In actuality it is a very complex system of related lookup tables. Since I cannot predict all the variants of services and pieces of services that may be offered, the system was built to allow the administrator to dynamically add and remove qualities from the service profile. Certainly a detailed specification could have made that simpler but would have resulted in a limited application where as this one can grow to meet the future needs of the client (I know..the simpler approach would have produced more billable hours in the future..blah blah).

Of course, the service provider has to have their own website to be able to manage the details of their service without having to labor the administrator. However, the client does not want the service provider to be able to make certain changes to the profile without approval. So I have had to create a change request table in the database to accept pending changes from the service providers to be accepted or rejected by the administrator. Now there’s a level of complexity that echoes changes throughout the site!

I love my work!

add a comment

Tech Issue of the Day July 26, 2007 1:37 pm

Posted by Doug McCaughan in : ColdFusion, Daily Life, MySQL, Programming, Technology
, 2comments

Today’s terribly frustrating error causing a long delay in a short process is:

Parameter index out of range (1 > number of parameters, which is 0).

It is the result of this simple insert:

<cfquery name="createrole" datasource="#application.gDataSrc#">
    INSERT INTO #application.projectidentifier#_theroletable {
       fooASInt,
       barAsInt
    } VALUES {
       <cfqueryparam cfsqltype="CF_SQL_INTEGER" value="#fooAsIntValue#">,
       104
    }
</cfquery>

UPDATE: Whoops. I see the typo! There is a big difference between {} and (). Should have been:

<cfquery name="createrole" datasource="#application.gDataSrc#">
    INSERT INTO #application.projectidentifier#_theroletable (
       fooASInt,
       barAsInt
    ) VALUES (
       <cfqueryparam cfsqltype="CF_SQL_INTEGER" value="#fooAsIntValue#">,
       104
    )
</cfquery>

2comments

And an afternoon of troubleshooting goes to one line July 25, 2007 4:19 pm

Posted by Doug McCaughan in : ColdFusion, HTML, Programming, Technology
, add a comment

So IIS v6 wasn’t letting form variables post. <cfdump var="#form#"> would show an empty structure. CF’s built-in webserver on the development box worked fine. Changing the method from post to get made things even stranger with the query string using &amp; instead of &. I finally found the solution. I had used the obscure html tag <base"

<base href="http://domain.com/">

IIS v6 did not like this. Removing that one line fixed the problem. So much for trying to be the perfect coder.

add a comment

Attention CFers! Alagad is Hiring July 10, 2007 2:55 pm

Posted by Doug McCaughan in : ColdFusion, Programming, Technology
, add a comment

Alagad sounds like the kind of company I always wanted to start. If you are an advanced CF developer, and want to work from home with a flexible schedule, this opportunity might be for you!

add a comment

Programming challenge! July 10, 2007 10:53 am

Posted by Doug McCaughan in : ColdFusion, Daily Life, Programming, Software, Technology
, 3comments

I’ve submitted my question to the TinyMCE support forum. Can you figure it out before they can?

3comments

Today’s Technical Challenge July 10, 2007 6:53 am

Posted by Doug McCaughan in : ColdFusion, Programming, Software, Technology
, add a comment

As a web application developer, I am often asked to put a WYSIWYG editor into the application so that the end-user can use the application without having to learn HTML and CSS. There are plenty of free and commercial wysiwyg editors available. (Note to developers: bookmark that link!)

These editors are designed to be customized for your application. You can typically control what buttons appear, what the interface looks like, and so forth. My challenge is to not only change the appearance of the editor, but when the end-user begins typing I need to have that type appear in a default font family (Arial), font size (12pt), and justified to the left. That means if they cut and paste content the defaults need to be applied.

The editor I chose for this project was TinyMCE. I find it far easier to implement than the ever popular FCKeditor (and no..those are the developer’s initials). My editor of choice is typically Xinha.

I have found numerous references to setting content_css : "defaultcontent.css" in the tinyMCE.init and this does change the text as the end-user is typing but the font family select and the font size select menus remain at their default values. When you save, the font family and font size are not saved. Very frustrating.

Interesting!

May 3, 2007 – Adobe, to embed FCKeditor in ColdFusion 8

Adobe has chosen FCKeditor as one of the great new features of its next major release of ColdFusion, code-named Scorpio. Some reviews of it can be found on the web.

For ColdFusion programmers, it will be as easy as defining a tag to see FCKeditor displaying all its power on their pages, right out of the box.
[Source]

add a comment

MySQL and CFMX7 July 6, 2007 11:47 am

Posted by Doug McCaughan in : ColdFusion, MySQL, Programming, Technology
, add a comment

I’m jumping the hoops again on another server.

Update: After beating my head into the wall, bleeding on my keyboard, restarting a server and having it almost not come back to life, I realized that "commysql.jdbc.Driver" and "com.mysql.jdbc.Driver" are not the same thing. Oh the angst that can be caused by missing a period!

add a comment

ColdFusion 8 to be much faster June 27, 2007 1:00 pm

Posted by Doug McCaughan in : ColdFusion, Programming, Technology
, add a comment

Ben has the numbers.

add a comment

Like quicksand! June 19, 2007 8:44 pm

Posted by Doug McCaughan in : ColdFusion, Daily Life, Programming, Technology
, 2comments

So today began with me frantically trying to complete one project so that I could try to finish another critical project and was interrupted with a client emergency which was put on hold until tomorrow. Part of wrapping up project 1 involved getting the data and structure out of a MS SQL 2k database and into a MySQL 5.03 database. Jumped some hoops on that one. The MySQL GUI Tools are fantastic! I still prefer SQLyog for developing queries since it uses the same shortcuts as MS Query Analyzer. Next I had to figure out how to get my CFMX7 server to actually connect a data source to the MySQL server.

Long and short I had to download the mysql-connector-java-5.0.6.zip then put the jar into the web-inf/lib directory. The CFservice had to be restarted of course. Worked like a charm!

Devpapers.com was invaluable although I skipped most of those instructions.

Ended up on a long tech support call trying to figure out why my Motorola v3xx has quit sending SMS text messages and will only send MMS messages. Seems the answer may be to empty everything from the inbox and outbox. That will take some doing!

Time to do more programming. What I’d really like to do is settle in with a scotch and a book or a movie and talk to Cathy.

2comments

Where are all the CF developers? February 28, 2007 9:06 pm

Posted by Doug McCaughan in : ColdFusion, Programming, Technology
, add a comment

Do you code in ColdFusion? If so, put yourself on the map.

add a comment

What is programming? November 24, 2006 12:30 pm

Posted by Doug McCaughan in : ColdFusion, Daily Life, Programming, Technology
, 1 comment so far

In essense, a client presents a challenge and I solve the problem.

Today’s challenge: a custom ordering system (shopping cart) written in ColdFusion is producing the wrong totals.
The system design: tax is built into the price of the items stored in the database except for certain non-taxable items. A flag indicates if an item has tax built into the price or not. At the bottom of the invoice, the amount of tax charged is shown.
The problem: The system allows for the administrator to apply a discount. Tax cannot be discounted but the total tax shown on the invoice is calculated off the discounted price.

How do you solve this kind of problem? I use my tools available to me. I could just jump into the code and start changing it but I can do a better job and document my efforts by using MS Excel and MS Word to help solve the problem.

  1. I pull up the sample invoice that the client used to show the incorrect figures.
  2. I reproduce the invoice in Excel.
  3. I open the database (in this case with MS Access) and find the products listed on the invoice so that I can be certain which items are taxed and which are not.
  4. I manipulate the spreadsheet to assure that I am using the correct math formulas to get the correct result.
  5. Find the code within the system that calculates the tax and change it to use the new formula for presentation.

Update: I think perhaps the end of this post was lost…

1 comment so far

Interpretting ColdFusion Error Messages November 11, 2006 3:20 pm

Posted by Doug McCaughan in : ColdFusion, Programming, Technology
, add a comment

Everyone knows what Apple’s "Type 1" error message means. Well, you should. It means "something went wrong and we have no clue why!" Everything computer related has something like this. Even AdoMacrollaire’s ColdFusion has some strange ones.

Invalid token ‘\n’ found on line 40 at column 0.

This error message means you forgot to close a comment somewhere. ColdFusion comments are delineated the same as HTML comments (<!– html comment here –>) but with an extra dash (<!— cfml comment here —>). So if you open a comment and forget to close it perhaps even following it with another comment you will get the reference to a linefeed (\n) being an invalid token.

<!--- this is the messed up comment
<!--- and this is a valid comment --->

add a comment

Looking to go corp October 18, 2006 3:17 am

Posted by Doug McCaughan in : ColdFusion, Daily Life, Programming, Software, Technology
, 1 comment so far

I love working for myself. I love working from the house. I have worked the past 9 weeks for free because I was unable to collect on my last two major projects. My business practices have to change to prevent this from happening again.

There are five companies in the Knoxville area that could woo me back into corporate life: Scripps Networks, Jewelry Television, Bush Beans, SAIC (wow! SAIC IPO’d!), and Clayton Homes. I am sure there are others. I really know my stuff when it comes to ColdFusion. PHP, MS SQL and MySQL. ColdFusion is my love. I learned yesterday that Jewelry Television has a ColdFusion position available and I am applying. Wish me luck!

1 comment so far

Securing Contacts and Jobs October 16, 2006 11:32 am

Posted by Doug McCaughan in : AJAX, ColdFusion, Daily Life, MySQL, Programming, Technology
, add a comment

I just put a resume out on this one. Sounds fun!

Duties and Responsibilities:
- Assist in composing web pages and in creating special sections as assigned by the Site coordinator
- Work hands-on in the development of web applications (AJAX/HTML/Javascript)
- Competence creating table-free layouts
- Prototype, develop, and maintain new features and enhancements
- Operates as a leader/lead worker among other staff, shares knowledge or training with subordinates and/or colleagues to benefit the entire department
- Participate in workflow design and analyze existing production and implementation processes in order to insure the overall quality of the sites
- Maintenance and support of existing templates and content production processes
- Perform web development, template writing, testing debugging, documentation, and installation tasks for on-line processes in accordance with industry best practices and specific internal procedures and standards
- Partner with Web-ops to ensure that interactive techniques and technologies translate through to shipping products and services
[Source]

One of the challenges of working for yourself is you have to shoot at a lot of barns to hit some work. The problem is barns move pretty quick! Sometimes it is just plain difficult to find a barn. Then the barn’s owner looks at you and may not even give you permission to shoot at the barn in the first place much less give you the barn.

Playing low budget developer and sales person at the same time can lead to missed deadlines or living with very little sleep. Finishing a project, then turning on sales mode can lead to dry spells where you wonder how you’ll eat. Ideally, you should be working with a sales person!

add a comment

ColdFusion Event Gateway / Web Service Gave Me Trouble August 17, 2006 1:21 pm

Posted by Doug McCaughan in : ColdFusion, Daily Life, Programming, Technology
, add a comment

My programming love is ColdFusion. I have been working with it since early 1998 with the release of version 3. Version 8 will release next year. A feature of CFMX7 that I have not had the opportunity to use is the Event Gateway to turn a CFC into a web service.

ColdFusion event gateways are ColdFusion MX elements that let ColdFusion MX react to or generate external events or messages in an asynchronous manner. Event gateways let a ColdFusion application handle information that does not come through an HTTP request. For example, you can use event gateways to handle instant messages, short messages from mobile devices, or messages sent to a TCP/IP port. [Source]

The Project

I have a project that uses XML feeds to update inventory status from a wholesaler to the reseller. Unfortunately, do to problems at the wholesaler end, one of the feeds is unavailable and will remain so. The solution is to use a query of the database to obtain IDs of the active products then use CFHTTP to get the information from the wholesaler’s website (site scraping). Since there are roughly 1500 active products at any one time, making 1500 CFHTTP calls at once causes timeouts as the browser gives up before the webserver can finish its task. Since this update will be done only occasionally, 1500 requests to the wholesaler is not a big deal.

The Solution

The solution to the problem is to implement the CFHTTP request as a CFC, create a gateway instance with a 5 minute timeout, and call the gateway instance with small groups of product ids from a .cfm page. The concept works beautifully since the Event Gateway is asynchronous and decoupled from the browser which initiated the instance.

The Problem

I choose the .cfm to manage grouping the product IDs so that there would only be one query instead of 150 queries (~1500 products in groups of 10) as would happen if the query were within the CFC. So the code builds a list of IDs within a structure (as required by the Event Gateway)

The onIncomingMessage method must take a CFEvent structure that contains input information in its Data field, and processes the contents of the Data field as needed. [Source]

The loop that calls the gateway instance builds the list, calls the instance, clears the list, builds the next list, calls the instance, and so forth. Apparently I am able to alter the datastructure so quickly that the second list replaces the first list before the gateway instance fires so the CFC ends up processing only the information from the latter lists. More simply, the CFC processes whatever data is in the structure at the time the gateway event fires from the queue not the state of the structure at the time the gateway event was called by the ColdFusion application. Set up a gateway instance and try the following code. This is the CFC to which the gateway instance will be associated.

test.cfc

<cfcomponent displayname="Test Gateway" hint="Logs the idlist passed into the CFEvent.Data structure.">
   <cffunction name="onIncomingMessage" access="remote">
      <cfargument name="CFEvent" type="struct" required="yes">
      <cflog
         text="Gateway test complete for ids #CFEvent.Data.idlist#."
         file="GatewayTest"
         type="Information"
         application="Yes">
   </cffunction>
</cfcomponent>

The calling CF application is show below

test.cfm

<cfscript>
   datarange = structNew();
   tmplist = "8,1008,1019,1020,1021,1022,1024,1025,1026,1027,1030";

   datarange.idlist = duplicate(tmplist);
   datarange.datasource = "adult";

   status = SendGatewayMessage("TestGateway", datarange);

   tmplist = "8,20,19,18,17,16";

   datarange.idlist = duplicate(tmplist);
   status = SendGatewayMessage("TestGateway", datarange);
</cfscript>

You would expect the log file to have two different lines.

Gateway test complete for ids 8,1008,1019,1020,1021,1022,1024,1025,1026,1027,1030
Gateway test complete for ids 8,20,19,18,17,16

but instead it has two identical lines.

Gateway test complete for ids 8,20,19,18,17,16
Gateway test complete for ids 8,20,19,18,17,16

The Solution

I have not tested the solution yet but I am betting that I either

  1. have to let the CFC call the gateway instance after it has processed a batch of ids thus making this a synchronous process to itself but still asynchronous to the browser or
  2. Create a unique structure for each group of IDs to be processed

I prefer the latter. Update: Testing is complete and solution #2 works great!

Other Resources

About event gateways
Abobe’s (fomerly Macromedia formerly Allaire) overview
Deploying an event gateway
Macrodobellaire’s livedocs for initial setup of an event gateway
Using the CFML event gateway for asynchronous CFCs
This was the most helpful livedoc with critical information non-chalantly hidden within such as "Using the CFML event gateway for asynchronous CFCs"
SendGateWayMessage
Livedocs for SendGatewayMessage
The Asynchronous CFML Gateway – A Real-World Example of a Great New Technology
Matthew Woodward comes through in this ColdFusion Developer’s Journal article
Understanding Asynchronous Processing by Ben Forta
It wouldn’t be ColdFusion unless Uncle Ben said something.
Concurrency Library
It is very difficult to mention asychronous CFML without someone mentioning Sean Corfield’s work.
XML Path Language (XPath)
XPath is a language for addressing parts of an XML document, designed to be used by both XSLT and XPointer.
XPath Axes
XML Lessons at W3Schools

add a comment