Jake Churchill

… on Flex, ColdFusion, FarCry, and much more …

  • Home
  • About
  • Projects

8

Feb

FCKEditor Firefox 3.6 Bug (Year 2010 Bug)

Posted by Jake Churchill  Published in Uncategorized

The new version of Firefox broke my FCKEditor! They didn't do it on purpose I'm sure, but it did, in fact, break it. I am using what I consider the standard implementation in ColdFusion (that does not come bundled with ColdFusion). I updated my Firefox to the most recent version (3.6) which was released on January 28 and BOOM! Goodbye WYSIWIG.

The implementation uses the standard CFC (fckeditor.cfc) which includes a function in a file called "fckutils.cfm". Line 47 of that function looks like this:

stResult = reFind( "gecko/(200[3-9][0-1][0-9][0-3][0-9])", sAgent, 1, true );

This new release was released in 2010 so the first part of the string after "gecko/" fails. Changing that line to this will fix the problem:

stResult = reFind( "gecko/(20[0-9][0-9][0-1][0-9][0-3][0-9])", sAgent, 1, true );

I can't really take the credit. I found the solution on Pete Freitag's blog. Here's his post: http://www.petefreitag.com/item/737.cfm

1 comment

3

Feb

ColdFusion using Java for regex replace

Posted by Jake Churchill  Published in Uncategorized

Yesterday, I found myself needing more than ColdFusion could supply. I had a variable with content that came from a WYSIWYG editor. Some of that content was the result of inserting images into the content. By default the image source was set to the absolute path from the webroot (i.e. /images/imagefile.jpg). This worked great for the web, but I needed the same content to be sent via email which did not work so well.

I needed to find all instances of the “src” attribute and tack on a domain so the ending result would be http://domain.com/images/imagefile.jpg and therefore would be email friendly. I tried several ways of doing this (combinations of REFind, REMatch, etc) but everything ended up being more difficult than it should have been.

Luckily, a ColdFusion String maps directly to a Java String so even though the docs might not suggest it, there are methods available for use. The one I wanted was “replaceAll()”. It does a simple regex replace and allows for backreferencing ($1, $2, etc). Backreferencing is key to not lose content that I needed (i.e. /images/imagefile.jpg). So, here’s the code that finally made my day:

<cfset domainName = "http://domain.com" />
<cfset contentVariable = contentVariable.replaceAll("src=\""(\/.+?)\""", "src=\""#domainName#$1\""") />

Full documentation on Java’s String functions can be seen at the Java Docs -> String

6 comments

2

Feb

ColdFusion VirtualMerchant CFC

Posted by Jake Churchill  Published in ColdFusion

One of the biggest requests I get is to explain how I integrated a ColdFusion app with the VirtualMerchant Gateway. It was actually quite simple. The difficulty lies in the lack of documentation and help from VirtualMerchant. Their gateway does not seem to allow for much customization or control.

If you want to have a user click a button and be sent to VirtualMerchant’s payment terminal for the payment processing, it’s great. But it is more difficult to allow the user to stay on your site and use VirtualMerchant only for the payment processing.

Here’s what I did:


continue reading "ColdFusion VirtualMerchant CFC"

no comment

28

Sep

Farcry Navigation Move Permissions

Posted by Jake Churchill  Published in Farcry

I received a question today about how to stop the contributor policy group from being able to re-order navigation nodes. There are a lot of things that you can control via the group permissions section. For some information on those, see this post: http://www.reynacho.com/?p=49.

However, these permissions deal primarily with the approval process and webtop sections. dmNavigation does not go through the standard approval process and basically everyone can access the site tab. So, how do we accomplish this?

Basically, we set up node-specific permissions. I have discussed this before in creating a Members Only Section but we can control users who have webtop access in a similar way.

In order to stop contributors from being able to re-order Navigation Nodes, we need to turn off the “Move” menu and sub-menu. How do we do that? Well, a quick read through /core/tags/navajo/overview.cfm gave me my answer. Please do not read this file without a king-sized bottle of Ibuprofen handy. In my version 4.0 install around line 1244 I found my answer. Move checks to make sure the user has “Edit” permissions on the node in question. So, let’s turn those off:

  1. Make sure you are logged in as an admin
  2. Go to the Site Tab and find the node you want to limit
  3. Right click and select “Permissions”
  4. Change the select box to Contributor (or any other group you wan to affect)
  5. Change “Edit” to “No” (or “Inherit” if you’ve already set this to “No” on a parent node)

And there you go, the Contributor group no longer gets the “Move” menu.

On a side note, thank you to the guys on this thread for bringing this up.

no comment

14

Jul

Delete Mail via POP Script

Posted by Jake Churchill  Published in ColdFusion

I’ve had an issue come up several times in the last month where I’ll get several thousand emails from sites on errors or notifications or whatever. I have no choice but to be on the list to receive the emails and I was sick of trying to manage all of them (most of them just got deleted anyway) so I thought I’d write a script to do the deleting for me. You can see the script below (with certain data such as usernames and passwords removed for privacy):

continue reading "Delete Mail via POP Script"

no comment

21

May

Flex 2 Datagrid not highlighting row (UPDATE)

Posted by Jake Churchill  Published in Flex

I recently posted a solution about the DataGrid in Flex 2 not highlighting rows correctly after certain events (specifically double-clicking a row). You can read that post here.

I wanted to simply update the code sample that I gave for the overridden drawRowBackground() method. The code I had before was from Flex 3 and introduced a bug that I (for the life of me) couldn’t find. So, I re-wrote it much more simply and this time it takes full advantage of the super class’s implementation rather than using Flex 3′s source. Here you go:

override protected function drawRowBackground(s:Sprite, rowIndex:int, y:Number, height:Number, color:uint, dataIndex:int):void
{
var rowColor:uint = color;
if( this.selectedIndices.indexOf(rowIndex) != -1 )
{
rowColor = getStyle("selectionColor");
}
super.drawRowBackground(s, rowIndex, y, height, rowColor, dataIndex);
}

You can see, I’m simply overriding the color which is all I wanted to do in the first place. I don’t know why the best solutions always come after you leave and revisit the code but so be it.

no comment

20

May

Flex 2 Datagrid not highlighting row

Posted by Jake Churchill  Published in Flex

I had an issue in a Flex 2 project yesterday where a Datagrid would not highlight the selected row. All the styles were set up for this but it still would not work. The unfortunate matter is that this project (at least for the time being) is stuck in Flex 2 which is not open source.

I dug into the Flex 3 source code for Datagrid (I don’t recommend this unless you need to). I found a method called drawSelectionIndicator() which gets called to set up the selection. There are several methods that get called overall but the one that finally does the background color is drawRowBackground(). Somewhere down the line, the color being passed to drawRowBackground was not what was set in the stylesheet (see below). So, I created a custom DataGrid class that extended the original and overrode the drawRowBackground method. The source code is from Flex 2 so I made a few changes to make it work in Flex 2. Here it is:

continue reading "Flex 2 Datagrid not highlighting row"

1 comment

15

May

Flex Dynamic casting of data

Posted by Jake Churchill  Published in Flex

I have been playing around with an AIR application which stores data to a local SQLite DB. I have a very basic settings table which is nothing more than a key/value paring of settings. The keys all match up with variables in the Model. So, there’s a setting for “fontFamily” which is both the key and the Model variable name. I had the following basic settings:

  • fontFamily (String)
  • fontColor (uint)
  • backgroundColor (uint)
  • startAtLogin (Boolean)

The way SQLite works, it is just easier to store things as VARCHARs and convert them as needed, so how was I going to convert all of these?

My initial thought was to use a switch statement. That way I could cast each variable based on the key. That wouldn’t be so bad for this small amount of settings but it simply would not do for a larger application. I know that the data stored in the DB is going to be able to be converted to whatever data type I need (i.e. “true” can be converted to Boolean, “#FFFFFF” can be converted to uint, etc). So, I came up with this snippet of code that’s been working great for me so far. All settings are loaded into an acSettings ArrayCollection in the model initially so that is what I’m looping over:

if( Model.getInstance().acSettings.length )
{
var settingVO:SettingVO;
var className:Class;

for( var i:int = 0; i < Model.getInstance().acSettings.length; i++ )
{
settingVO = Model.getInstance().acSettings.getItemAt(i) as SettingVO;
className = Class( getDefinitionByName( getQualifiedClassName( Model.getInstance()[settingVO.key] ) ) );
Model.getInstance()[settingVO.key] = settingVO.value as className;
}
}

Piece by piece, here’s what happens:

  • I first get the variable in the model correponding with the current setting key: Model.getInstance()[settingVO.key]
  • Then I get the class name of the model variable with this: getQualifiedClassName( Model.getInstance()[settingVO.key] )
  • Then I get the class definition with this: getDefinitionByName( getQualifiedClassName( Model.getInstance()[settingVO.key] ) )
  • Finally, I cast that as a Class using Class( getDefinitionByName( getQualifiedClassName( Model.getInstance()[settingVO.key] ) ) );

The result is that I get whatever the classname of the variable is stored as a class in my “className” variable which I use in casting in a loop.

Just so you know there’s nothing else going on, my SettingVO class is nothing more than this:

package com.reynacho.Reminder.vo
{
[Bindable]
public class SettingVO
{
public var settingID : Number; // primary key
public var key : String;
public var value : String;

public function SettingVO (settingID:Number, key:String, value:String)
{
this.settingID = settingID;
this.key = key;
this.value = value;
}
}
}

no comment

8

May

Reboot XP PC over Remote Desktop

Posted by Jake Churchill  Published in Misc

I work from home sometimes and in the past have had to reboot my PC due to the usual random reasons. Over a Remote Desktop connection it does not give you that option by default. It just gives you the option to log off or disconnect.

Servers give you the option to reboot so I thought, why not PCs?

Well, there is a way and you don’t have to jump through any major hoops to do it. Simply open the run dialog or a command shell and type
shutdown -r

the -r is VERY important here, otherwise, you’ll just shutdown your computer.

I hope that helps someone.

EDIT: Please not this is on Windows XP Pro. I’m not sure about other Operating Systems

EDIT 5/20/2009: The easiest way yet is to hit Alt+F4 and select “Restart”

3 comments

8

Apr

Dynamically instantiate a class

Posted by Jake Churchill  Published in Flex

I ran into a problem today where the most elegant solution was to dynamically instantiate a class. However, I couldn’t for the life of me figure out how to do that. Basically, the situation was this:

  1. Dispatch Event A
  2. If Event A Fails, Dispatch Event B, then re-dispatch Event A.

This dealt with a SQLite database and query statements. I want to run a Select query but if the table has not yet been created, I need to create the table then re-try the query. Here’s what I ended up doing…

In the fault of the select statement I dispatch the create table event and pass it an optional string (the class that I want to instantiate). In the create table command, I then dynamically create that class and instantiate it. Here’s the code:

Fault of Select Command:
new CreateTableEvent("com.test.cairngorm.events.SelectAllEvent").dispatch();

Create Table Event:
package com.test.cairngorm.events
{
import com.adobe.cairngorm.control.CairngormEvent;

public class CreateTableEvent extends CairngormEvent
{
public static const CREATE_TABLE_EVENT:String = "com.test.cairngorm.events.CreateTableEvent";
public var nextAction:String;
// constructor
public function CreateTableEvent(nextAction:String='')
{
this.nextAction = nextAction;
super( CREATE_TABLE_EVENT );
}
}
}

Result of Create Table Command:
// sourceEvent.nextAction is the string that I passed in
if( sourceEvent.nextAction.length )
{
// dynamically create a class based on the string
var c:Class = Class( getDefinitionByName( sourceEvent.nextAction ) );
// instantiate that class into a generic Object
var o:Object = new c();
// test if the object is a CairgormEvent.
// if so, dispatch that event
if( o is CairngormEvent )
CairngormEventDispatcher.getInstance().dispatchEvent(CairngormEvent(o));
}

Thank you very much to http://thillerson.wordpress.com/2007/03/01/runtime-class-instantiation-in-actionscript-30/ for pointing me in the right direction.

no comment

Search

Blog Feed

  • Add blog to any reader
  • Comments Rss
June 2013
M T W T F S S
« Feb    
 12
3456789
10111213141516
17181920212223
24252627282930

 

June 2013
M T W T F S S
« Feb    
 12
3456789
10111213141516
17181920212223
24252627282930

Subscribe to Blog

Your email:

Subscribe   Unsubscribe

Archives

Categories

  • Browsers (3)
  • CFEclipse (2)
  • ColdFusion (7)
  • CSS (9)
  • Farcry (33)
    • Farcry Examples (2)
    • Farcry Users (1)
  • Flash (1)
  • Flex (14)
  • Javascript (5)
  • Life & Fun (3)
  • Microsoft Office (1)
  • Misc (4)
  • Random Posts (1)
  • SQL (2)
  • Uncategorized (2)

Blogroll

  • Axel Jensen
  • Ben Forta
  • Coldfusion Muse
  • Fullasagoog
  • Nicole Rutter
  • Ray Camden
  • Sandy Clark
  • Stillnet Studios

Recent Posts

  • FCKEditor Firefox 3.6 Bug (Year 2010 Bug)
  • ColdFusion using Java for regex replace
  • ColdFusion VirtualMerchant CFC
  • Farcry Navigation Move Permissions
  • Delete Mail via POP Script

Recent Comments

  • James Moberg on FCKEditor Firefox 3.6 Bug (Year 2010 Bug)
  • Jake Churchill on ColdFusion using Java for regex replace
  • Ben Nadel on ColdFusion using Java for regex replace
  • Peter Boughton on ColdFusion using Java for regex replace
  • Peter Boughton on ColdFusion using Java for regex replace

Recent Post

  • FCKEditor Firefox 3.6 Bug (Year 2010 Bug)
  • ColdFusion using Java for regex replace
  • ColdFusion VirtualMerchant CFC
  • Farcry Navigation Move Permissions
  • Delete Mail via POP Script
  • Flex 2 Datagrid not highlighting row (UPDATE)
  • Flex 2 Datagrid not highlighting row
  • Flex Dynamic casting of data
  • Reboot XP PC over Remote Desktop
  • Dynamically instantiate a class

Recent Comments

  • James Moberg in FCKEditor Firefox 3.6 Bug (Year 2010 Bug)
  • Jake Churchill in ColdFusion using Java for regex replace
  • Ben Nadel in ColdFusion using Java for regex replace
  • Peter Boughton in ColdFusion using Java for regex replace
  • Peter Boughton in ColdFusion using Java for regex replace
  • Matthew in ColdFusion using Java for regex replace
  • Matthew in ColdFusion using Java for regex replace
  • Jake Churchill in Flex Channel.Connect.Failed error NetConnection.Ca…
  • Flex Guy in Flex Channel.Connect.Failed error NetConnection.Ca…
  • Dexter in Flex Custom Preloader without SWF
© 2008 Jake Churchill is proudly powered by WordPress
Theme designed by Roam2Rome