ColdFusionUsers.com

Developers Blog


BlueDragon 7 Dynamic Datasource Creation

Posted by christopher on October 21st, 2007

I’ve recently accomplished having my application rebuild its datasource when the application is created in BlueDragon 7. I’m not sure how supported this is going to be by New Atlanta, but a neat little hack anyways. First let me state that while this seems like an odd thing to do, the purpose of this was to allow users of my application to modify a configuration file to setup their datasource instead of have them muck around in the BD7 Admin.

For ease of display, I’ve removed the code where I read the parameters from the file. Also, I only do this when the application starts - you could embed this into a configuration or install page instead.

All code below uses <--- comment ---> which excludes the exclamation point. This is because this blog software seems to consider them as actual comments to be ignored even when in code blocks.

<--- Connect the the BlueDragon Admin --->
<cfset bdadmin = CreateObject( "component","bluedragon.admin")>

<--- Initialize  with BD Admin Password --->
<cfset variables.tmp = bdadmin.init('password')>

<--- Remove Existing Datasource --->
<cftry>
	<cfset variables.tmp = bdadmin.removedsn(variables.dsname)>
	<cfcatch type="any">
		
	</cfcatch>
</cftry>

<-- Create New Datasource -->
<cfset variables.tmp = bdadmin.adddsn(
		'sqlserver'
		,lcase(variables.dsname)
		,variables.dbname
		,variables.description
		,variables.dbsrvr
		,variables.dbport
		,variables.dbuser
		,variables.dbpass
		,'120'
		,'3'
		,'120'
		,''
		,''
		,'true'
		,'true'
		,'true'
		,'true'
		,'true'
		,''
		,''
		,''
)>

I probably spent an hour before I was able to come up with the first parameter (sqlserver). I looked at the BD XML Configuration file, looked at JTurbo sites, guessed at them, but they all failed saying that they weren’t valid. I finally got sqlserver from a complete unrelated page that was listing various database types and realized I hadn’t tried that variation yet. Other values that seemed to work were “mysql” and “postgresql”. While I didn’t test it, I assume the value “oracle” would work as well.

Now, what are all those parameters that I’m not using variables for? You can expose them as follows:

<--- Connect the the BlueDragon Admin --->
<cfset bdadmin = CreateObject( "component","bluedragon.admin")>

<--- Initialize  with BD Admin Password --->
<cfset variables.tmp = bdadmin.init('password')>

<--- Dump It! --->
<cfdump var="#bdadmin#">

This includes a list of everything you can call using the BDADMIN component. Scroll down to addDSN to see what parameters can be manipulated. Good luck!

Bookmark to:
Add 'BlueDragon 7 Dynamic Datasource Creation' to Del.icio.us Add 'BlueDragon 7 Dynamic Datasource Creation' to digg Add 'BlueDragon 7 Dynamic Datasource Creation' to FURL Add 'BlueDragon 7 Dynamic Datasource Creation' to blinklist Add 'BlueDragon 7 Dynamic Datasource Creation' to My-Tuts Add 'BlueDragon 7 Dynamic Datasource Creation' to reddit Add 'BlueDragon 7 Dynamic Datasource Creation' to Feed Me Links! Add 'BlueDragon 7 Dynamic Datasource Creation' to Technorati Add 'BlueDragon 7 Dynamic Datasource Creation' to Socializer 

Posted in Code Snippets, Tips and Tricks, BlueDragon | No Comments »

cfQuickDocs Plugin Issues Resolved

Posted by christopher on October 21st, 2007

The cfQuickDocs Firefox Plugin issues have been resolved. Thanks to the few folks that emailed me and posted comments. Looks like when I made some template changes I lost a bit of javascript - whoops! Anyone who is not using the cfQuickDocs plugin should check it out!

Bookmark to:
Add 'cfQuickDocs Plugin Issues Resolved' to Del.icio.us Add 'cfQuickDocs Plugin Issues Resolved' to digg Add 'cfQuickDocs Plugin Issues Resolved' to FURL Add 'cfQuickDocs Plugin Issues Resolved' to blinklist Add 'cfQuickDocs Plugin Issues Resolved' to My-Tuts Add 'cfQuickDocs Plugin Issues Resolved' to reddit Add 'cfQuickDocs Plugin Issues Resolved' to Feed Me Links! Add 'cfQuickDocs Plugin Issues Resolved' to Technorati Add 'cfQuickDocs Plugin Issues Resolved' to Socializer 

Posted in ColdFusionUsers | No Comments »

How to Tell if CFSCHEDULE is Calling Your Page

Posted by christopher on September 22nd, 2007

For one reason or another you may need to determine logically if a page you are coding is being called by CFSCHEDULE. The way I’ve done this in the past is by examining the CGI scope for the http_user_agent. I’m not sure about older or newer versions of ColdFusion, but with CFMX 7, ColdFusion passes “CFSCHEDULE” as the value. So in your code you could do something like:

<cfif cgi.http_user_agent is "CFSCHEDULE">
     This page is being called by CFSCHEDULE.
<cfelse>
     This page is not being called by CFSCHEDULE.
</cfif>

Since it’s the job of the web browser (or any application requesting a web page) to pass the HTTP_USER_AGENT string, I would recommend against using this exclusively in any type of access or security function since someone could easily change their agent value to CFSCHEDULE. I’d love to hear what other ways people are doing this.

Bookmark to:
Add 'How to Tell if CFSCHEDULE is Calling Your Page' to Del.icio.us Add 'How to Tell if CFSCHEDULE is Calling Your Page' to digg Add 'How to Tell if CFSCHEDULE is Calling Your Page' to FURL Add 'How to Tell if CFSCHEDULE is Calling Your Page' to blinklist Add 'How to Tell if CFSCHEDULE is Calling Your Page' to My-Tuts Add 'How to Tell if CFSCHEDULE is Calling Your Page' to reddit Add 'How to Tell if CFSCHEDULE is Calling Your Page' to Feed Me Links! Add 'How to Tell if CFSCHEDULE is Calling Your Page' to Technorati Add 'How to Tell if CFSCHEDULE is Calling Your Page' to Socializer 

Posted in Code Snippets, Tips and Tricks | No Comments »

My Jump into AJAX

Posted by christopher on September 12th, 2007

In the last few weeks I’ve been toying a bit with AJAX in some simple demo ColdFusion apps - pretty much just testing the waters. For anyone who, like me, has been slow to adopt AJAX, it’s time to jump in. I’ll try and post some of my little samples for anyone who might be thinking of trying it out sometime soon. In the mean time, here was my experience…

I decided to try the two most popular (in the usergroups and forums anyway) AJAX components out there: CFAjax and AjaxCFC. I read up a bit on both of them and there’s no one out there that’s really dismissing either - most people agreeing that they each have their pros and cons.

For no good reason whatsoever, I tried CFAjax first. It was very easy to install and the setup instructions were very straightforward. I got it all set, ran a test to make sure it was working, and life was good. I spent about an hour trying to get my own AJAX application to work on top of it, and I honestly couldn’t. Maybe I had missed a step, or maybe I was overlooking the obvious somewhere, but it just wasn’t happening. I decided to move on and try the next one, coming back to this if I needed to later.

AjaxCFC was a whole different story. Setup was a breeze (not that CFAjax wasn’t, they both were very easy), and I immediately got a new test application working - first try! After getting a pretty basic function working that would just accept text I entered, manipulate it in some way and pipe it back out, I wanted to test out some queries. This proved just a smidge more difficult. At no fault of AjaxCFC, I couldn’t figure out how to manipulate the query data once it was returned from the server. After reading up (it’s been a while!) on my javascript, I got it going.

For anyone who runs into this as their first snag, you reference your query as follows:

returnvar.column_name[row_number]

For example:

r.country_name[2]

Now obviously you can plop your variables in there and have a dynamic AJAX application running in no time! Kudos Rob Gonda for AjaxCFC

Bookmark to:
Add 'My Jump into AJAX' to Del.icio.us Add 'My Jump into AJAX' to digg Add 'My Jump into AJAX' to FURL Add 'My Jump into AJAX' to blinklist Add 'My Jump into AJAX' to My-Tuts Add 'My Jump into AJAX' to reddit Add 'My Jump into AJAX' to Feed Me Links! Add 'My Jump into AJAX' to Technorati Add 'My Jump into AJAX' to Socializer 

Posted in ColdFusion, AJAX | No Comments »

Create Multiple Web Sites Under Windows XP

Posted by christopher on September 10th, 2007

I feel very strongly that this is one of those times when I’m way behind on the times, but I’ve added a new tool to my belt called IISAdmin.NET. This application will allow you to run multiple websites on your Windows XP Professional machine (out of the box you are limited to just one). While you cannot run them simultaneously, it is very easy to switch between sites using an icon in your system tray. All of the actual site configuration is still done using the Computer Management console.

UPDATE: Finally got around to trying out IIS 7 on Windows Vista Home Premium Edition and looks like Microsoft has removed the single site restriction with this release of the operating system.

Bookmark to:
Add 'Create Multiple Web Sites Under Windows XP' to Del.icio.us Add 'Create Multiple Web Sites Under Windows XP' to digg Add 'Create Multiple Web Sites Under Windows XP' to FURL Add 'Create Multiple Web Sites Under Windows XP' to blinklist Add 'Create Multiple Web Sites Under Windows XP' to My-Tuts Add 'Create Multiple Web Sites Under Windows XP' to reddit Add 'Create Multiple Web Sites Under Windows XP' to Feed Me Links! Add 'Create Multiple Web Sites Under Windows XP' to Technorati Add 'Create Multiple Web Sites Under Windows XP' to Socializer 

Posted in IIS Web Server | No Comments »

Action Canceled in Internet Explorer When Using CFCONTENT to Download File

Posted by christopher on August 30th, 2007

I’ve recently been troubleshooting an application that fails when run on Internet Explorer with the error “Action Canceled”. The page itself was pretty simple and something I had done many times before - it dynamically generated an RTF document and then prompted the user to download the file. After a few hours of minor tweaks to my code, and plenty of time scouring Google, it turns out that IE was generating this error because I was calling the page that was doing the download in a new window. Not sure why, but I guess this is a no-no. I changed my link to open in the current window instead of a new target and it immediately started working.

For what its worth, Firefox had no problem figuring out what I was trying to do.

Credit where Credit is Due, solution was found here:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/Cold_Fusion_Markup_Language/Q_22403538.html

Bookmark to:
Add 'Action Canceled in Internet Explorer When Using CFCONTENT to Download File' to Del.icio.us Add 'Action Canceled in Internet Explorer When Using CFCONTENT to Download File' to digg Add 'Action Canceled in Internet Explorer When Using CFCONTENT to Download File' to FURL Add 'Action Canceled in Internet Explorer When Using CFCONTENT to Download File' to blinklist Add 'Action Canceled in Internet Explorer When Using CFCONTENT to Download File' to My-Tuts Add 'Action Canceled in Internet Explorer When Using CFCONTENT to Download File' to reddit Add 'Action Canceled in Internet Explorer When Using CFCONTENT to Download File' to Feed Me Links! Add 'Action Canceled in Internet Explorer When Using CFCONTENT to Download File' to Technorati Add 'Action Canceled in Internet Explorer When Using CFCONTENT to Download File' to Socializer 

Posted in Internet Explorer, ColdFusion | 2 Comments »

Required JAVA Update to Support New TimeZones

Posted by christopher on January 18th, 2007

As you might already be aware, 2007 brings new time zone rules for most of the US and Canada. This marks the first time the rules have changed in quite a long time. To make sure that ColdFusion MX knows what the new rules are, you should upgrade your servers copy of JVM. The following Adobe tech note gives links to the downloads, as well as installation instructions:

http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=d2ab4470

Bookmark to:
Add 'Required JAVA Update to Support New TimeZones' to Del.icio.us Add 'Required JAVA Update to Support New TimeZones' to digg Add 'Required JAVA Update to Support New TimeZones' to FURL Add 'Required JAVA Update to Support New TimeZones' to blinklist Add 'Required JAVA Update to Support New TimeZones' to My-Tuts Add 'Required JAVA Update to Support New TimeZones' to reddit Add 'Required JAVA Update to Support New TimeZones' to Feed Me Links! Add 'Required JAVA Update to Support New TimeZones' to Technorati Add 'Required JAVA Update to Support New TimeZones' to Socializer 

Posted in ColdFusion | No Comments »

Automatically Cleaning Up Your ColdFusion Temp Files

Posted by christopher on November 7th, 2006

I build the following into a scheduled task recently to cleanup my CF temporary files. I put files here when they’re uploaded, being processed, or temporary attachments that are being mailed out. Because of my mail spooler settings, I’d rather not CFFILE DELETE them immediately, but rather a day or so later.

<cfdirectory name="tmpFiles" action="list" directory="#GetTempDirectory()#">

<cftry>
 <cfloop query="tmpFiles">
  <cfif DateDiff('d',tmpFiles.datelastmodified,now()) gt 1>
   <cffile action="delete" file="#GetTempDirectory()##tmpFiles.name#">
  </cfif>
 </cfloop>
 <cfcatch type="any">
  <cfset variables.return_code = 1>
 </cfcatch>
</cftry>

I use return_code elsewhere to report on the status of tasks; you can obviously setup any time of error handling you like. Simple code that helps me make sure that it gets cleaned up.

Bookmark to:
Add 'Automatically Cleaning Up Your ColdFusion Temp Files' to Del.icio.us Add 'Automatically Cleaning Up Your ColdFusion Temp Files' to digg Add 'Automatically Cleaning Up Your ColdFusion Temp Files' to FURL Add 'Automatically Cleaning Up Your ColdFusion Temp Files' to blinklist Add 'Automatically Cleaning Up Your ColdFusion Temp Files' to My-Tuts Add 'Automatically Cleaning Up Your ColdFusion Temp Files' to reddit Add 'Automatically Cleaning Up Your ColdFusion Temp Files' to Feed Me Links! Add 'Automatically Cleaning Up Your ColdFusion Temp Files' to Technorati Add 'Automatically Cleaning Up Your ColdFusion Temp Files' to Socializer 

Posted in Code Snippets, Tips and Tricks | No Comments »

Accessing Remote File Shares

Posted by christopher on November 5th, 2006

I see questions posted in various places regarding ColdFusion applications trying to access remote network shares. The most common problem in doing this is getting denied access — and the most common troubleshooting step is logging into the server and accessing the share. They can often access the share just fine. Unfortunately, this thought process is flawed. The reason is because ColdFusion is not running as any user who is logged in, it is running using a service account (such as one you’ve created, or LocalSystem). This account probably doesn’t have access to the remote share.

To check which user’s context that ColdFusion is running under, follow these steps:

  1. Right Click My Computer, then select Manage.
  2. If you’re not on the server, right click Computer Management, click “Connect to Another Computer” and pick your CF Server.
  3. Expand Services & Applications.
  4. Click the Services Item.
  5. Right Click the ColdFusion Application Server service, select properties.
  6. Select the Log On Tab.

If “Local System Account” is selected, you can be 99% certain that ColdFusion will have no access to any network shares at all. Otherwise, you’ll now know exactly which account is running ColdFusion. This is the account that you’ll want to make sure has permission to access the share you’re looking for. When possible, you should login to a workstation with the account to test security permissions. If the account is granted access to a share, it’s often necessary to restart the service before it will take effect.

Bookmark to:
Add 'Accessing Remote File Shares' to Del.icio.us Add 'Accessing Remote File Shares' to digg Add 'Accessing Remote File Shares' to FURL Add 'Accessing Remote File Shares' to blinklist Add 'Accessing Remote File Shares' to My-Tuts Add 'Accessing Remote File Shares' to reddit Add 'Accessing Remote File Shares' to Feed Me Links! Add 'Accessing Remote File Shares' to Technorati Add 'Accessing Remote File Shares' to Socializer 

Posted in Tips and Tricks | No Comments »

Storing Too Much in Variables - My Lesson Learned

Posted by christopher on October 25th, 2006

As part of a recent a ColdFusion project, I needed to query an Oracle database and accept anywhere from 0 to 30k-40k records, then export into a CSV. It didn’t seem like too difficult of a problem at first. I used Toad to build the perfect query. Once optimized to pull down the max amount of records in the least amount of time, I copied to ColdFusion, built my front end, tested, and released. How’d I do it? Seemed simple — I setup a variable with a CSV header row, and then appended the variable record by record with the new data, and at the end CFFILE’d it all into a temp file which I then presented to the user.

Almost immediately after releasing the page into the application, I started having memory issues on my ColdFusion box. I’d watch the task list and just see JRUN rise to unreasonable percentages, and every so often - just hang. Killing the process and restarting the service was the only solution. It was obvious that the report was the problem, and it needed to be fixed ASAP.

The solution is something that should have come to mind immediately. Trying to store upwards of 30k records in a variable probably was not the smartest solution I’ve come up with, and probably was maxing out those few gigs of RAM that I have allocated to that box. My solution? Instead of writing the data out to a temp file when I had collected it all to begin with, I change the code so that it would export after I had a complete record, and then clearing the variable. Not only did this alleviate all of the JRUN issues I was having, but also sped up the report significantly.

My lesson learned? Just because you can do something, doesn’t mean it’s the best way; take time to think. Unfortunately deadlines will often conflict with your ability to reason with your code ;)

Bookmark to:
Add 'Storing Too Much in Variables - My Lesson Learned' to Del.icio.us Add 'Storing Too Much in Variables - My Lesson Learned' to digg Add 'Storing Too Much in Variables - My Lesson Learned' to FURL Add 'Storing Too Much in Variables - My Lesson Learned' to blinklist Add 'Storing Too Much in Variables - My Lesson Learned' to My-Tuts Add 'Storing Too Much in Variables - My Lesson Learned' to reddit Add 'Storing Too Much in Variables - My Lesson Learned' to Feed Me Links! Add 'Storing Too Much in Variables - My Lesson Learned' to Technorati Add 'Storing Too Much in Variables - My Lesson Learned' to Socializer 

Posted in Tips and Tricks | No Comments »


Designing in coldfusion will not give you cold like some other languages. You can use a web host that provides you some of the best hosting services. Then a web template can be easily designed in this language especially for file sharing purpose. Its always good to work on the informative numbers 70-291 and 646-361 that will give you an edge in the network world.