ColdFusion Muse

Cfwindow Positioning Trial and Error

Mark Kruger November 6, 2007 11:17 AM Coldfusion MX 7, Coldfusion 8 Comments (1)

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.

Read More
  • Share:

Branch Target Offset Error

Mark Kruger September 28, 2007 2:06 PM Coldfusion MX 7, Coldfusion Troubleshooting Comments (3)

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.

Read More
  • Share:

One Way to Easy Recovery of a Crashed Server

Mark Kruger September 6, 2007 9:40 AM Coldfusion MX 7, Coldfusion Troubleshooting Comments (3)

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.

  • Share:

Site by Site Missing File Handler in IIS

Mark Kruger September 7, 2006 2:29 PM Coldfusion MX 7, Coldfusion Tips and Techniques Comments (6)

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.

Read More
  • Share:

Superfluous Data Binding Can be Good for You

Mark Kruger August 23, 2006 9:51 AM Coldfusion Optimization, Coldfusion MX 7 Comments (2)

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.

  • Share:

Matching MIME and Extension After Upload

Mark Kruger August 10, 2006 10:58 AM Coldfusion MX 7, Coldfusion Tips and Techniques Comments (1)

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

Read More
  • Share:

MIME Types, Coldfusion and You

Mark Kruger August 2, 2006 11:06 AM Coldfusion MX 7, Coldfusion Tips and Techniques Comments (4)

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:

Read More
  • Share:

Innovative Multi-Server Configuration Uses

Mark Kruger July 5, 2006 2:01 PM Coldfusion Optimization, Coldfusion MX 7 Comments (2)

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.

  • Share: