ColdFusion Muse

Cfwindow Positioning Trial and Error

I love the new widgety stuff in Coldfusion 8. The Cfwindow tag caught my attention right away. it seemed like a quick and easy way to frame content on a page and make it manageable. For example, I had a list of items that appear on the home page of our tracking system. It's the "hotlist" - a list of open and active work orders and projects. I decided to use Cfwindow to make it draggable and re-sizable. It was easy.

<cfwindow
        height="475"
        resizable="True"
        initshow="True"
        x="380"
        y="150"
        closable="False"
        draggable="True"
        title="Hot List"
        name="hotlist"
        headerstyle="background-color: ##A7B3C2;">

Some looping code that outputs a list of links.
</cfwindow>
This worked splendidly. I ended up with exactly what I wanted - a nice scrolling window that was easy to drag and resize to accommodate more entries.

Since I loved the little drop shadow thingy I decided I would use it on the right hand side menu as well - just to frame in the menu with a header. Oops... this turned out to be quite difficult. Why? Because there is no way to anchor the window to the layout. The layout is dynamic on the right. The right hand menu "clings" to the right side of the screen - meaning the X and Y coordinates are different for each screen size. But the Cfwindow appears over whatever is on the screen and the "x" and "y" coordinates make it's position absolute. I went hunting for an answer.

[More]

Branch Target Offset Error

Recently I got an error I had never seen before. That's news in itself. This error was especially cryptic. The template in question made a CreateObject() call to a CFC that was quite lengthy. In fact, this CFC was over 2000 lines of code (Coldfusion 7). When it tried to compile the code it threw an error that said branch target offset too large for short. You know you are a true geek when seeing an error you have never seen before raises your pulse. I started hunting for a solution - and I found one.

[More]

One Way to Easy Recovery of a Crashed Server

Everyone should have regular backups and a plan for restoring a server if something goes wrong. But let's say, for the sake of argument, that you have a problem with a server where all you have is the old drive with the Coldfusion install directory (c:\cfusionmx7\ for the sake of our scenario). If you have to do a reinstall, is there a way to get back all that careful tuning, datasources (there can be a lot of these), debugging IPs, settings, CFX tags, Mail settings, etc.? Actually it is not as hard as you think.

Do a fresh install to the same location as before (C:\CfusionMX7 in this case) being careful not to overwrite the old directory. You may need to rename that old directory if you are using the same drive over again. Once CF is completely installed and running, stop the server and any associated services like search, odbc server etc. Then install the "old" directory over the new. Use a rename if you like. The main issue is that the old directory should replace the new. Restart the services and log into the CF admin. If the admin fails to come up may have to rerun the "connector" script for your web server (found in CfusionMX7/bin/connetors). These magic scripts set ports and other things that "hook" your Coldfusion server into your web server.

Now before you add mean comments please know that I am aware there are other ways of doing this. You can grab several config files and anything that is an XML file from the old directory and simply copy them into the new directory and it will work. You can use wsconfig to recreate the services - possibly without a reinstall. I'm sure there are clever people out there that have all kinds of nifty tricks. This is just one trick that takes care of this scenario. But this trick is especially useful when you have to walk an inexperienced tech through it over the phone. The concepts are easy to understand and easy to guide someone through.

Site by Site Missing File Handler in IIS

Perhaps you've used my previous blog on IIS and missing file handlers to solve the problem of dynamically named folders or files. You might think that using the 404 handler in IIS in conjunction with your site wide missing template handler (set in the CFIDE Administrator) is your only option. What if you are on a shared server? Is there a way to implement a site by site missing template handler? Why yes Virginia there is.

[More]

Superfluous Data Binding Can be Good for You

If you have read my previous posts on "Execution Plans" and Data Binding you know I am a big believer in using Cfqueryparam for performance as well as security. Today I picked up a tip on this topic from harelmalka.com (a blog I had never read before). I had never considered it before, but a query with no "WHERE" clause does not using binding because it lacks the opportunity. Therefore, a statement like:

<CFQUERY ...>
      SELECT * FROM Users   
   </CFQUERY>
Would not include a prepare statement and not hit the execution plan. Hmmm.... The solution (originally detailed by Barny) is to add a superfluous binding merely for the purpose of kicking off the "prepare statement" method. Like so:
<CFQUERY ...>
      SELECT * FROM Users   
      WHERE 1 = <cfqueryparam cfsqltype="CF_SQL_INTEGER" value="1">
   </CFQUERY>
That get's the job done nicely.

Matching MIME and Extension After Upload

Muse Reader Asks:
How can I check that the extension of an uploaded file matches the mime type?

If you read my previous post, I presume what you mean is "how do I make sure the file is what it says it is". Unfortunately this is not as easy as it seems. MIME, as it turns out, has little to do with the file. It's an attribute that tells an OS what to do with content after it's been transmitted. In fact, MIME was originally designated as a way of setting up boundary containers in an email message to facilitate attachments. As you may know, SMTP only handles character data - not binary data. When you send an attachment it is actually encoded as character data. The MIME type tells the receiving client to put the file back together as a certain type of file. That's pretty much where MIME ends...

[More]

MIME Types, Coldfusion and You

Sometimes you need to be able to specify the MIME type using Cfcontent or inline headers to force the file to open in the proper application. If you have a document storage application or a data export application you know what I mean. For example, an engineering firm might upload CAD files, Office files, PDFs, images, and proprietary formats that you have never seen before. If you are like me, you end up writing code that switches against the file extension to set the mime type. Yesterday I saw a note from Dan Switzer from Pengoworks (of qForms fame) that can get the mime type using the file path. It's not perfect as I'll explain - but here it is:

[More]

Innovative Multi-Server Configuration Uses

Ben Forta posted this item on CF-Talk while discussing the nuances of moving to a multi-server instance. I thought it was a great illustration of some of the uses of CF Multi-server.

Ben Forta wrote:
It sounds like you are considering dedicated specialized instances, and I am a big fan of this. There is one customer I work with who has several sites in a single instance, like you do, but they have also created specific instances for specific needs. They have one that just does mailing, it receives requests from other instances, and process them. They have another which executes report requests on scheduled intervals. And another that builds Verity indexes when needed. These specialized instances require fewer threads, fewer data sources, no RDS and debugging (which you'd never want enabled on production servers anyway), and so on. That works very well. Of course, you may also want separate instances for specific apps, but that is a separate discussion.

I especially love the idea of a specialized instance for verity indexes. Re-indexing Verity collections is a huge resource hog, and larger collections can cause problems. I don't know why I never considered this approach before - very ingenious.

A Case for a Higher Default "Simultaneous Request" Setting

In a technote titled Coldfusion Performance Tuning that was last updated on March 7th 2003, the following advice was given regarding the "simultaneous request" setting in the Coldfusion administrator. The writer indicates that this setting has the largest impact on scalability, and then goes on to recommend a setting of 3 times the number of processors as a "starting point". This number has been oft stated as the "rule of thumb". I've heard as 2 to 3 requests per processor and I've often heard the number of 4 to 5 per processor, although I was unable to locate that recommendation in any online documents. I think this baseline recommendation should be changed to as high as 7 to 10 per processor for a CFMX server on a modern server (P4 or Xeon).

[More]

Jrun Processor Pegging Issues and Solutions

Lately I've been involved in a couple of troubleshooting sessions where JRUN on a CFMX server was causing 95% to 100% processor utilization. Unfortunately I have not yet stumbled onto a magic bullet for this. Tweaking memory settings, changing garbage collection routines, modifying the threads for the scheduler and the simultaneous requests all seem to help, and in some cases solve the problem. I have never found one single solution that solves this problem. It usually comes down to either JVM arguments or an external process (a database, queue, COM, FTP etc) that is causing a hanging request.

Today, however, I stumbled upon a solution that seemed to solve the problem immediately. If your processor spike is due to this specific issue then this seems to fix it. Keep in mind, that I'm basing that opinion on the fact that taking the following steps seems to have fixed a production server in my care - so take it for what it's worth.

[More]

Coldfusion MX and Mqseries Revisited

In my previous post on the topic of integrating MQSeries with Coldfusion MX I included some sample code for sending and retrieving messages to "put" and "get" queues using an MQManager object. This post has a correction and addition to that original sample code.

[More]

Configuring CF 7 Multiserver Instances - Including Custom JVM Settings

Multi-server Installation have some distinct advantages. Process isolation is the one that makes the most sense to me. Many, maybe most servers house more than 1 web site. Even Intranet servers seem to have more than 1 site configured. A "single site" server is pretty rare - at least outside of a cluster. Having a way to isolate 1 site from another on the server itself is an ideal way of keeping bad code or database connections on one site from dragging down another. It's not for everyone. It certainly adds another layer of complexity to your server. Still, it's an excellent solution in some cases. Consider this scenario.

[More]

Working With IBM's MQSeries and Coldfusion MX

This post may be one that very few of my readers will care about. But if you are the 1 reader in 1000 that needs to know how to connect to MQSeries version 6 using coldfusion then this post may prove a life saver. You can benefit from the 50 hours of my life I spent figuring this out that I will never get back. Here's the scoop. We have a client who needs to upgrade a Coldfusion installation running on CF 5. The current installation uses COM. Under a load it becomes unresponsive.

NOTE: There is an update to this post that was entered on 4/24.

[More]

Server-side Vs. Client-side Validation Revisited

CF Muse Reader Asks:
You suggest both client and server side should be used for validation. Just to check - I should code so that js picks up the errors first using event code or onsubmit then let server side pick up the errors on submit using cfinput validate/required etc. Or do I recode all the stuff to be event driven such as onchange etc.

This question refers to the previous post on form validation. From the way the question is phrased I believe the reader is probably proficient at JavaScript. There are some amazing things you can do with JavaScript, and I'm in favor of creating intuitive interfaces that help your user cope with the complexity of your application. Obviously JavaScript is or can be a big part of that solution. If your concern is to provide a better user experience then JavaScript is helpful and necessary. If your concern is to validate your data for accuracy and security then you must use server side code to check your form inputs.

[More]

CFMX and the Dot Operator - Migrating From CF 5 to CFMX

If you come from the old "Coldfusion 4-5" days (in fact many or our customers are still running CF 5) then you might remember how those earlier versions handled variables with periods in the name. If you created a variable with a period in the name CF simply treated the period as if it were part of the variable name. For example, if you did the following in CF 5:

<cfset var1.var2.var3 = "My Dotty Variable">

You would not have created anything more than a primitive variable named "var1.var2.var3". If you tried to use <cfdump ...> to dump out var1 it would generate an error - var1 not found. If you intended for var1 to be a structure containing a structure var2 containing a primitive var3 then you would have to rewrite the code like this:

<cfset var1 = structNew()>
   <cfset var1.var2 = structNew()>
   <cfset var1.var2.var3 = "My Dotty Variable">
Fast forward to CFMX.

[More]

More Entries




Blog provided and hosted by CF Webtools. Blog Sofware by Ray Camden.