Category: ColdFusion

I am building a new site on my server that will be another Mango Blog. Mango is not setup for running multiple instances like it would be nice if it did, but very easily you can at least use the same file base. While this won't save you much on anything other than disk space for the CF Files and for the file cache if your CF server has that turned on; it certainly is nice to have one install location instead of 2 or 3.

To do this you will need to edit only 2 files:

  1. Application.cfm
    • Change the "this.name" setter on line 7ish to something that would be URL driven. In my case I used:
      this.appKey = replaceNoCase(cgi.server_name, "www.", "");
      this.name = "mango_#right(hash(this.appKey),50)#_v1_4";
    • The around line 41 you will find a reference to config.cfm. I've replaced this with: config_#this.appKey#.cfm
  2. admin/setup/Setup.cfm
    • Using the same method as Application.cfm I created an appKey var in the function saveConfig. Around line 268/269 will be two references to config.cfm; again replace these with: config_#this.appKey#.cfm

Now Mango Blog will be using config files based on the server name of the current site. The only secondary change I made was in the config files themselves.

  • Make sure the tablePrefix values are different
  • I adjusted my asset directories to be unique per site: assets/content/{new site name}/

For months I've thought about the power of virtual machines. I use them all the time now for production and staging servers and in the past I've used them for QA purposes in a lab. However I have never run a VM instance on my own box.

Recently I purchased a VMWare Workstation 6.5 license on the cheap and on a re-wipe of my laptop decided to put it into use. I now have multiple XP VMs, a Win Server and an OpenSUSE distro. I am now able to have multiple server setup options at my fingertips with ease.

Setup
After several setup attempts I think I have found a great mix.

  1. All of my development tools and code are located on my real machine.
  2. All of my services are located on a VM
  3. All of my services via UNC paths call on files from the HOST machine.
    • This allows me to have multiple servers from multiple VMs reference [easily] the same code set.


Things To Pay Attention To

  1. Setting up the networking can be difficult the first time, but it really is easy. I choose to run everything in NAT mode; just make sure your firewall settings are all correct. I've also made all of my Windows machines part of the same workgroup to make some file browsing easier.
  2. Permissions: In my case I created a VMUser in my VMs that was an admin/root and on my main box created that same user. I made sure VMUser had read/write too all of the relevant files. I then made sure all of my services were running as that user.
  3. Flex / Flash Development and Debugging: Because you will be launching your debugging on an IP such as 192.168.248.x instead of 127.0.0.1 your Flex Builder will be unable to attache to the debug tool from the browser. When you launch your flash/flex app right click on the flash app area. When you click you will see a menu item "Debugger"; click it. You will get the following pop-up. When you do change the selected option from localhost to other machine and enter 127.0.0.1. Viola, your debugger will now attache!


So far my experience is extremly positive. I recomend a minimum of 4 gigs; this is what I currently have and I would want no less. My next laptop will definetly have either 6 or 8 gigs to allow me to run multiples at the same time, or maybe even make a VM my full time editing area. VMs can do multi-monitor BTW! I would love to have my base OS be basically naked and be able to more easily do snapshots and go backwards in time. For me, setting up all the servers takes the most time. Now I can just backup my VMs and on a future wipe of my box, literally be up and running in say an hour instead of 5 or 6.

A little while ago I started using a screenshot of our flex app login to use as the background for a few of our web apps. As usage grew I ran into multiple color and title needs. So instead of doing things the simple way and just using Photoshop, I decided to make this an example of taking and using "screen shots" (not using mx.graphics.ImageSnapshot).

First I built a plain-jane panel component that I wanted to use as my background in my HTML based application

Then in my main MXML file I wrapped the login component and 3 empty canvases in one larger canvas. I did this in order to more easily control position inside the greater app while easily being able to build my Rectangles.

<mx:Canvas id="loginForm" backgroundColor="{this.backgroundColor.selectedColor}" width="400" height="296">   
    <local:LoginForm title="{this.windowTitle.text}" borderColor="{this.panelColor.selectedColor}" width="360" y="15" horizontalCenter="0"/>
    <mx:Canvas id="loginHeader" width="368" height="48" y="11" horizontalCenter="0"/>
    <mx:Canvas id="loginBody" width="368" height="59" y="78" horizontalCenter="0"/>
    <mx:Canvas id="loginFooter" width="368" height="67" y="219" horizontalCenter="0"/>
</mx:Canvas>


I positioned the 3 boxes to be in the size and position of my 3 desired screen shots: A header, a repeating body and a footer. In my code I use these to create a very easy way to visualize what I'm capturing. In the real world outside of my very specific goal these might be controllable by the end-user.

To create my screen caps first I take a snap of the entire formpublic function takeSnapshot():void {
    var imageSnap:ImageSnapshot = ImageSnapshot.captureImage(this.loginForm);
    var imageByteArray:ByteArray = imageSnap.data as ByteArray;

    var loader:Loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, getBitmapData)
    loader.loadBytes(imageByteArray);
}


Then I loop over my 3 targets to create the specific sub-images that I need:
var bd:BitmapData = Bitmap(e.target.content).bitmapData

for each (var target:Canvas in [this.loginHeader, this.loginBody, this.loginFooter]) {
    rect = new Rectangle(target.x, target.y, target.width, target.height);

 bd2 = new BitmapData(target.width, target.height);
    bd2.copyPixels(bd, rect, pt);

    var m : Matrix = new Matrix();
    bd2.draw( bd2, m );

    encoder = new JPEGEncoder(100);
    ba = encoder.encode(bd2);

    rawImages[target.id] = ba;
}

this.amfService.save(this.downloadUUID, rawImages);



The flex app has view source enabled and the ColdFusion code for the backend is included as well...

 

Are you getting the error "Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Status 200"? I thought I bloged about this last month but apparently not. Upon upgrading to IE8 on my Windows XP Pro dev box I could not get any of my flex apps with AMF services to work. It appears as though not everyone hits this wall, even in my own test, it works from Windows 7 but not from XP.

The Adobe Bug entry for this has picked back up speed thanks to some votes and new supporting comments. I'm really suprised this has not gotten more attention, but maybe for some reason this isn't as wide spread as it could be. Or it's just that IE8 addoption is that low?

http://bugs.adobe.com/jira/browse/SDK-21005

I was trying to access an ColdSpring generated remote facad from Flex this morning when I got this error. It worked just fine by calling CFINVOKE and by calling the CFC directly in the browser. From my flash/flex app it however did not work. I hit my head for several minutes before finding the utmost simple solution.

I have multiple CF instances and it turns out that I did not fully setup the current instance to my liking. So if you see this error, check to make sure that your use-mappings settings is set to true in your services-config.xml file. Flipping this switch resolved my issue.

<use-mappings>true</use-mappings>