Creating An Exploded View Of Flat Hierarchal Data Using Coldfusion

One of the things that I have been looking at lately is how to handle hierarchical data in an efficient way. One of the ideas that has made the most sense was to store the hierarchical information in a flat table structure with references to a parent item in each row.

In a very simplistic view of the data, we could look at the data as an associative array with some random data:

<cfscript>
flatTable = StructNew();

flatTable["1"] = "root";
flatTable["2"] = "1";
flatTable["3"] = "1";
flatTable["4"] = "1";
flatTable["5"] = "2";
flatTable["6"] = "5";
flatTable["7"] = "3";
flatTable["8"] = "3";
</cfscript>

This is a nice representation of my table as I can easily reference any member without worrying about the depth of the hierarchical structure. However, there may be times when I need to explode the structure into a more fleshed out structure. To accomplish this, there are several scenarios for parsing the structure.

[More]

Refresh Coldfusion Web Service WSDL definition stub programmatically

Working on a project that requires two coldfusion servers to chat with each other through web services; something I haven't had to do for many years now. Anyway, as soon as I made a change to my publishing CFC, my consuming CFC started complaining. Seems that the server caches the WSDL signature of the remote cfc. That is great for production, but not so much for development. So, practically crawling into the wayback machine, I quickly found Brandon Purcell's nearly 6 year old solution to Refreshing Web Service Stubs in ColdFusion MX. With two moments worth of added abstraction:

<cffunction name="refreshRemoteService" access="public" output="false" returntype="boolean">
<cfargument name="service" type="string" required="true" />
<cfset var _return = true />
<cftry>    
<cfobject type="JAVA" action="Create" name="factory" class="coldfusion.server.ServiceFactory" />     
<cfset RpcService = factory.XmlRpcService />    
<cfset RpcService.refreshWebService(arguments.service) />    
<cfcatch type="any"><cfset _return = false /></cfcatch>    
</cftry>
    
<cfreturn _return />    
</cffunction>

And here's a handy usage example:

<cfscript>
remoteWebPublisher = "http://www.remoteDomain.com/path/to/myRemote.cfc?wsdl";
refreshStatus = refreshRemoteService(remoteWebPublisher);

ws = Createobject("
webservice",remoteWebPublisher);
myResult = ws.myRemoteMethod();
</cfscript>

Something worth remembering.

Refresh Coldfusion Web Service WSDL definition programmatically

Working on a project that requires two coldfusion servers to chat with each other through web services; something I haven't had to do for many years now. Anyway, as soon as I made a change to my publishing CFC, my consuming CFC started complaining. Seems that the server caches the WSDL signature of the remote cfc. That is great for production, but not so much for development. So, practically crawling into the wayback machine, I quickly found Brandon Purcell's nearly 6 year old solution to Refreshing Web Service Stubs in ColdFusion MX. With two moments worth of added abstraction:

<cffunction name="refreshRemoteService" access="public" output="false" returntype="boolean">
<cfargument name="service" type="string" required="true" />
<cfset _return = true />
<cftry>
    
<cfobject type="JAVA" action="Create" name="factory" class="coldfusion.server.ServiceFactory">     
<cfset RpcService = factory.XmlRpcService>    
<cfset RpcService.refreshWebService(arguments.service)>
    
<cfcatch type="any"><cfset _return = false></cfcatch>
    
</cftry>
    
<cfreturn _return />    
</cffunction>

And here's a handy usage example:

<cfscript>
remoteWebPublisher = "http://www.remoteDomain.com/path/to/myRemote.cfc?wsdl";
refreshStatus = refreshRemoteService(remoteWebPublisher);

ws = Createobject("
webservice",remoteWebPublisher);
myResult = ws.myRemoteMethod();
</cfscript>

Something worth remembering.

Tampa Coldfusion User Groups: Coordination Fail

So I was contemplating my first time attendance of the Tampa Bay Coldfusion User Group and wondering how it can start to grow; it has been around for awhile (I never attended before because I suck) and its leadership is changing hands. This was a good inaugural meeting for me as Greg Wilson, our very friendly and competent Tampa-based Adobe evangelist presented on the forthcoming Adobe 9 (centaur) and Coldfusion Builder (bolt). The attendees were a good group of guys (not being sexist, there were just, unfortunately, no ladies present) and I think there is a renewed energy to grow our local user group into something useful and vibrant.

So, while taking inventory of my swag - there is at least one upside to low attendance, though it isn't sustainable - I thought to do a search for "tampa coldfusion developers" and was happy to see that first in the list was an active blog from a Tampa coldfusion developer - potential member, tremendous. So, imagine my surprise to find out that he started his own Central Florida Coldfusion User Group on June 5, 2009. WTF?

First, it is a really, really good thing. Not the least of which as there seems to be no cross pollination between the groups. And it looks like there is a local pool of Coldfusion developers and otherwise interested people. The challenge now is to get the two groups talking and potentially joining together. The existing Tampa group is already well acquainted with Adobe and has really great sponsorship by Kforce - at the very least, Kforce provides excellent meeting space. The new group seems to be acquiring members and be enthusiastic about Adobe and Coldfusion.

However, I'm scratching my head wondering how this happened. Did the Aaron Greenlee, creator of the Central Florida Group, not search to see if there was an existing group? Why didn't the TBFusion guys know about this new group? (I can't say that I would have in their place) Is there something else going on? Hopefully it just all ends well. I'll do what I can to meddle help.

The takeaway, if there is one, is to scout your local area to see who is already meeting. If you have a group, there may be a way to improve your membership in a wholesale way. If you want to start a group, you may be in for a pleasant surprise.

Adobe Developer Day - Romania

It's good to see once in a while some positive news come out of my native country, Romania.

I am proud to say that the Romanian Adobe presence is doing well, and I wish them the best.

On that note, details about the Adobe Developer Day event in Bucharest, May 19, from Mihai Corlan, Adobe evangelist for Romania.

Coldfusion: RTFM

CFDUMP has lots of extra properties to make your life easier, but to make a short story long:

I should probably keep my discussions to more profound things, but since the following little tidbit has come up a several times in the last few days, it is probably worth mentioning just so I don't forget it.

As a programmer, I can get to be pretty damn lazy, and that sometimes mean relying on code hinting a bit too much. Luckily, I frequently shake myself free from it, particularly when I am in some strange machine using Notepad and the developer version of CF to solve some really odd job that would best be done with other tools. Anyway, the good thing about Notepad is that it really sucks and therefore forces me to know what it is I am supposed to be doing. And that is how I came to find out that CFDUMP will go straight to a file if you ask it nicely. This would be completely unremarkable except that my currently installed version of CFEclipse doesn't recognize the extra properties needed to do this.

In the most recent incidents, I was using a gateway to listen to a folder and I was helping Alex debug an issue located in the bowels of some very old spaghetti code - I was the cook so I guess I'm obliged to help, in at least some small way, make the inevitable changes. Anyway, these are all situations where there is no way to dump to the screen and it wouldn't even be practical to employ any sort of framework. In the case of my folder listener, the whole application is literally one method of roughly 10 lines in one cfc and its associated config file (and it replaces $2000 worth of dedicated software - long story, but sometimes I really love Coldfusion).

So even though nearly all my uses of CFDUMP look like <cfdump var="someVar"> the available options are way more extensive:

[More]

Modifying Files With Binary Data in Coldfusion

I've had some crazy, unproductive distractions, but I did have the occasion to solve a problem with Coldfusion that turned out to be a bit of a pain in the butt. Specifically, I had a requirement to modify a text file by adding an additional line based on the occurrence of a marker. This looked to be somewhat easy, and my first version was produced rather quickly. The problem is that while it looked to be the solution, it didn't work.

The catch was that the file on which I needed to work contained binary data, including some taboo characters. I should have known something was amiss when I was examining the file as I was unable to cut-n-paste the file as it contained null characters. So, in manual tests, I was forced to copy the file in whole, and then make modifications.

The first attempt was a straightforward attempt at reading the file line by line, injecting the additional line when needed.

fileMarker = "some text to be sought and appended";
appendText = "whatever text that needs to be added";

targetFileAddress = "path\to\address\file.ext";
updatedFileAddress = "path\to\address\updatedFile.ext";
targetFile = FileOpen(targetFileAddress);
updatedFile = "";

while(NOT FileisEoF(targetFile)) {
line = FileReadLine(targetFile);
updatedFile &= line;
if (Trim(line) eq fileMarker) {
updatedFile &= chr(13) & chr(10); // new line
updatedFile &= appendText;
}
updatedFile &= chr(13) & chr(10);
}
FileClose(targetFile);
FileWrite(updatedFileAddress,updatedFile);
This works well for text files, but the problem is that binary content is corrupted by this.

[More]

Support Your Local Actionscript User/Developer Group.

I attended the second meeting of the Tampa Flash, Flex and Air Developers Group this evening and, like the first, found it worthwhile. It helps that, in addition to our local Adobe Evangelist Greg Wilson, we also were graced by the presence of Ben Forta and Kevin Hoyt. The connectivity of the Flash Platform and Coldfusion is such that this meeting included the local Tampa Coldfusion Group (though the link has not been working for me this week) so it with something of a blend of Coldfusion and Flash developers which fits me like a glove.

Ben regaled us with live demonstrations of an alpha of the upcoming Coldfusion Bolt as well as a bit of discussion of the advantages of the CF9 with integrated hibernate. It seems like Adobe has set their mark on two Marks - I had this disturbing image of the Centaur Forta trotting around the fallen, arrow pierced bodies of Mark Mandel and Mark Drew. Of course, it is premature to announce the death of Transfer or CFEclipse, my prefered IDE, as we have yet to even begin playing with what Adobe has in store. And all the adobe evangelistas were pointed in their inability/refusal to reveal what business models Adobe will use to monetize their efforts.

[More]

Using XMLListCollection In Flex To Filter Coldfusion Queries

Another thing I have played with recently is binding Coldfusion qresultset to DataGrids. In my case, I wanted to filter the data based on input into a TextInput and also the selectedItem of a ComboBox. My natural inclination when working with query data is to want to use sql, however, that seemed like it wasn't going to fly easily in Flex. While I am sure that someone has at least considered creating a SQL parsing engine for Flash, that idea quickly fled and was replaced by a desire to use XML.

So the first thing I did was to create a function to convert my ArrayCollection. My standard caveat is that there is probably a better way to do this, but absent of having that way handily available, here's what I did:

[More]

Flex Embedded In PDF - Guest Starring Coldfusion And Flash Security Issues

One of the things that I think is really cool is that there is a full flash player in Acrobat 9. It is definitely a feature that looks useful as it allows you to embed some really powerful functionality into your documents and provides a totally different model for distributing a RIA.

Luckily, it has some potential importance to my day job, so when no one was looking, I scored a few moments to test it out. It was a really good exercise as it also give me a reason to actually think about the services.config.xml.

So, I started with a really simple Hello World style application. Of course, mine was more reminescent of two teenagers talking:

[More]

More Entries

BlogCFC was created by Raymond Camden. This blog is running version 5.9.1.001. Contact Blog Owner