cfwindow and JavaScript Gotcha

OK I’ll be honest, this is straight out of the docs, but I figure there may be one or two people out there that don’t read the docs, so it might be worth passing along.

Today I needed to create a <cfwindow> (a tag that I do like, in spite of being on the fence as to whether or not I think the AJAX bits really belong in CF… but that’s another post). The source was a page that already existed in another part of the site I was working on. This page made some pretty heavy use of JavaScript, and not surprisingly, my first efforts to display it resulted in dismal failure.

Read More»

42 Different Kinds of Awesome – CrossSlide jQuery Plugin

Via Scott Pinkston on #coldfusion…

While I haven’t had the opportunity to dive as deeply into jQuery as I’d like, I’ve incorporated quite a few jQuery plugins into some recent projects, and have always been impressed with the quality of the output as well as the ease of implementation.

Last night Scott brought the CrossSlide jQuery plugin to my attention. I’m definitely in awe.

The plugin plays an image “slideshow” of sorts. It utilizes a fade transition effect, as well as a panning effect to create an overall effect that I’d only previously seen done via Flash. There are a few configuration options as well, including the option of not panning the image, and panning/zooming (what they refer to as the “Ken Burns effect”).

This is one of those plugins that, unfortunately, I really have no need for at the moment… but it’s slick enough that I’ve been wracking my little brain trying to figure out how I could force it into an upcoming project :)

Check it out!

ColdFusion 8 – Enhancements You May Gave Missed

ColdFusion 8 – Enhancements You May Have Missed

A few weeks back, I was approached by Packt Publishing and asked if I’d be interested in writing an article for their article network. Their original request was about arrays in ColdFusion 8, but I asked if we could flesh it out a bit and cover some of the other enhancements that CF8 brought to the table. They were very accommodating and gave me quite a bit of leeway.

What’s really exciting about this to me is that, I believe this is the first ColdFusion-related article on their article network. And they approached me. It wasn’t as if I (or anybody else in the community) approached them and convinced them to accept an article on ColdFusion. They wanted a ColdFusion-related article. Hopefully it’ll be the first of many, as every little bit of exposure helps dispel the FUD that still pops up today regarding ColdFusion.

I’ll also point out that Packt is planning on releasing a ColdFusion 8 book, The ColdFusion 8 Developer Tutorial, written by John Farrar. Very nice to see a publisher getting behind ColdFusion, and I’m thrilled to be contributing even a small part to that.

Please feel free to check out the article and let me know what you think. In addition to feedback on the article, I’d love to hear some ideas for other topics that you think might be of interest.

Dealing with Form and URL Variables

It’s not terribly uncommon to have a page that is expecting a particular variable, but the page may not know if that variable will be in the form scope or URL scope. Case in point might be a resultset that does pagination. On the first submit, the variables would likely be in the form scope. As the user pages through the results, it’s entirely possible that the variables would be in the URL scope.

The most straightforward way to handle this would be:

<cfparam value="myNewVar" default="" />
<cfif structKeyExists(URL, 'myVar')>
	<cfset variables.myNewVar = URL.myVar />
<cfif structKeyExists(form, 'myVar')>
	<cfset variables.myNewVar = form.myVar />

It checks both scopes for the var, and if it finds the variable in either, it assigns it to a new local variable. It’s straightforward, but not particularly “clean”.

Read More»

Flex Images: Visible Property Funkiness in itemRenderer

In the Flex app that I’m currently working on, I have a DataGrid that uses an itemRenderer to display an image. The image is a ‘delete’ button that allows the user to delete the item. Fairly straightforward, and the code below was working fine…

<mx:DataGridColumn width="24" sortable="false" paddingLeft="4" paddingRight="4" headerText="">
			<mx:Image source="assets/icon_delete.png" horizontalAlign="center" height="17" width="17" click="parentDocument.confirmDelete(event);" />

… until the customer called and said that the user should not be allowed to delete a record if that record meets a particular condition. OK. I think I can do that. I made some modifications and now had the following code:

<mx:DataGridColumn width="24" sortable="false" paddingLeft="4" paddingRight="4" headerText="" dataField="CAN_DELETE">
			<mx:Image source="assets/icon_delete.png" horizontalAlign="center" height="17" width="17" click="parentDocument.confirmDelete(event);" visible="{data.CAN_DELETE == 1}" />

Read More»

MXML is XML (Duh?)

Just a quickie today, something that I came across while playing around with Flex. It could very well be a “duh, Charlie” observation, but i think it bears mentioning.

Flex makes it very easy to bind elements to other elements or objects. What this means is that a DataGrid, for example, can be populated by the contents of an ArrayCollection (for CF’ers, think of an ArrayCollection as an array of structures). The first step is to declare the variable as bindable in your <mx:Script> block:

	private var myArray:ArrayCollection;

Your DataGrid would then be declared as follows:

<mx:DataGrid dataProvider="{myArray}" id="myDataGrid">

The curly braces around the value of the dataProvider attribute indicates that it’s a bindable variable. All pretty straightforward. But there are other ways to use bind variables to influence the behavior of an element.

Read More»

Flex: Objects are like Structures. Kinda. (Part II)

Last night I started documenting my journey of learning Flex, focusing on my use of the built-in Object datatype and some issues that I faced in that respect.

There was one other aspect of this that I meant to touch on. To recap, I was passing a single Object to a ColdFusion CFC method. In my little ColdFusion brain, I thought of this as being not unlike a structure. So, I expected the method to receive a single argument much like a struct with multiple keys.

Let’s say my ActionScript function looked like this:

var args:Object = new Object();
args.stateCode = "CA";
args.zipCode = "94583";
args.territory = 3;

// call the remote object method

I created an Object, populated it with 3 variables (keys), and passed it as an argument to the getFilteredCustomers() method in my remote object (CFC). Originally, my CFC looked like this:

Read More»

Flex: Objects are Like Structures. Kinda.

Over the past few months I’ve been lucky enough to have the opportunity to start playing around with Flex at work. Overall it’s been a pretty good experience. I think Flex itself is a very cool technology, and FlexBuilder absolutely ROCKS as an IDE. Of course, there have been hurdles. Some I was able to overcome pretty easily, and some left scars. I figured I’d post some of them here and hopefully save some other Flex n00bs the hassle of figuring things out the hard way.

The application that I’m currently working on is fairly straightforward. Let’s call it a user manager. I present a couple of comboboxes that let the user filter by certain criteria (state,
zipcode, etc) and populate a DataGrid with the list of users that were returned.

I chose to pass these values in a single object. In ColdFusion, this single object would be a structure. Flex, or more appropriately, ActionScript, has a comparable datatype, simply called Object. an Object would be created as follows:

var args:Object = new Object();
args.stateCode = "CA";
args.zipCode = "94583";
args.territory = 3;

Fairly straightforward when compared to a ColdFusion structure:

<cfset args = structNew() />
<cfset args.stateCode = "CA" />
<cfset args.zipCode = "94583" />
<cfset args.territory = 3 />

Read More»

Transfer: First Impressions

Last night I downloaded and looked at Transfer, a ColdFusion based ORM, for the first time. To be clear, it’s the first time I’ve looked at any ORM. I’m more than a little unhappy. What the hell is wrong with me that I’ve never made an effort to use Transfer before? (that’s a rhetorical question. there’s not enough gigs of storage space on the Internet to answer. k thx).

How did this all finally come about? I’m working on a project that’s my first Model-Glue app that actually makes use of objects. I was told to use Transfer by more than a few people, but I didn’t want to add any more to the learning curve. It seemed to me that learning Model-Glue, ColdSpring, and OO was quite enough for my little brain.

Read More»

Persistent Whitespace Issue

I ran into an issue yesterday that I was able to resolve… but by going around it instead of really fixing it.

I needed to pre-populate a form field with a value that i retrieved from a CFC method. The method was called getUser(), which contained a struct of user properties. For example, #getUser().firstName# may have returned the string “Charlie”.

So i had the following bit of code:

	<input type="text" name="username" value="#getUser().firstName#" />

…which should have been fine and dandy. However, when I rendered the page, the value in the form field seemed to have some spaces pre-pended to it. Looking at the source, I saw the following:

<input type="text" name="username" value="
charlie" />

Based on that, it seemed that there was a newline character before the text. Should be easy enough to fix (famous last words).

I threw a trim() around the value, but that didn’t work. Fair enough. trim() works on spaces. I don’t believe it removes all whitespace characters (e.g. tab, newline, etc). Sounded like a job for regular expressions. In ColdFusion, the character class [:space:] is supposed to remove all whitespace characters (spaces, tabs, carriage returns, etc). Tried a rereplace(), but that didn’t work either (nor did \s, which is really functionally equivalent to [:space:], but i was running out of options).

Read More»
Page 5 of 6« First...23456
© Copyright Charlie Griefer