[Looking for Charlie's main web site?]

Handling optional arguments to web service method calls in CFMX 7

Note: This blog post is from 2006. Some content may be outdated--though not necessarily. Same with links and subsequent comments from myself or others. Corrections are welcome, in the comments. And I may revise the content as necessary.
Have you tried to invoke a web service method from CFML when it declares optional arguments, and you don't pass in those optional arguments? You get an inobvious error message. Well here's good news: there's a new solution in CFMX 7, with CFINVOKEARGUMENT's Omit="yes|no". Very nice.

Thanks to Steven Erat for pointing this out.

For those who have seen my presentation on CFML web services (at CFUNited and over the past few years in other venues), this has long been a sore spot for me. So glad to see it fixed.

Understanding (and monitoring) the CF template cache

Note: This blog post is from 2006. Some content may be outdated--though not necessarily. Same with links and subsequent comments from myself or others. Corrections are welcome, in the comments. And I may revise the content as necessary.
Adobe CF team member Ashwin has posted an entry offering some useful insights into the inner workings of the CF template cache. More detail from Adobe folks is of course always welcome. Thanks, Aswin.

I've posted a comment there about how to measure and report on whether and when template cache misses occur. (Again, read his post for more on what a means.)

I would have posted it as a trackback from here, but I don't see how to do that in BlogCFC. So instead, I'm pointing you to it this way. :-)

To save you the trouble, if you just want to know how to measure it, here's what I wrote:

Thanks, Ashwin. More detail from Adobe folks is of course always welcome.

But I do think it's useful to point out also how one can measure and report on whether and when template cache misses occur. There are at least two.

First, it's reported in the command-line CFSTAT tool as CP/Sec (for cache pops per second), and reports both a current and highwater mark. (Of course, you must enable CFSTAT support in the CF Admin, and the cfstat is in the cfusion/bin or cfusionmx/bin.)

It's also reported in the Windows Performance Monitor, by way of the ColdFusion/ColdFusion MX "performance object" counter called "Cache Pops/Sec" (again, assuming that you've enabled Perfmon support in the CF Admin).

With perfmon's ability to create logs and alerts, it should be easy for someone to create a mechanism to track if you ever have a non-zero value, which would suggest increasing the template cache size.

I meant also to mention that there is an old but still useful Allaire technote offering some more insight into caching, including using CFSTAT and more.

I-Spry Part 3: Some easy mistakes (I hope you will now avoid)

Note: This blog post is from 2006. Some content may be outdated--though not necessarily. Same with links and subsequent comments from myself or others. Corrections are welcome, in the comments. And I may revise the content as necessary.
As I explore Spry, one of the first demos I tried to write from scratch--rather than use code from an existing demo--was an experience that taught me a couple of lessons I now want to share with others.

(As suggested in the entry's title, this is part of a series I'm doing on Spry. Be sure to check out the other entries.)

Make sure you understand your XML

I made a mistake of trying to eyeball an XML file's layout to determine the nesting needed to create the XPath value for the XMLDataset constructor. Oops.

[If you're new to Spry, I've likely just gotten way over your head! This entry is for those already checking it Spry. Newcomers should leave right now and go check out the "bolded" resources I point to in my Spry compendium for that sort of help....Go on. I'm serious! You won't appreciate the rest otherwise! :-)]

I was looking at an RSS stream that looked like this (abbreviated):

<?xml version="1.0" encoding="utf-8"?><br>
   <rss version="2.0"><br>
   <channel><br>
   <title>Blogname</title><br>
   <item><br>
      <title>Blog entry 1</title><br>

So I thought that the "rss" element was outermost and the rest, including my desired "title", were all children, so I set the xpath to be rss/title. And I got no generated output from Spry. Doh! It should have been rss/channel/title.

Here's a tip: open the desired XML file with some tool that shows you the XML in a nested tree structure. Perhaps easiest, you can just open the file using IE or Firefox (as of 1.5), which will show it using a special stylesheet that renders the XML in a nested structure.

Of course, if the destination you try to open doesn't respond with pure XML, you won't even be able to open it effectively with such tools, which will tell you that you have another problem (like forgetting to turn off debugging if generating XML from CFML, or forgetting to cause the CFML page to change the mime type to text/xml. More on both of those mistakes in a later entry).

Don't use spry:region on Table tag

Interested in creating an HTML table? OK, no noise please from the CSS crowd. Some of us old-timers are slow to the party or just don't gravitate to it for quick testing.

Anyway, I mistakenly assumed that if I wanted to create a table of multiple rows that I would just add the spry:region tag to the Table tag. I figured that since I would naturally want the spry:repeat on the TR tags, I should put the enclosing spry:region on the enclosing TABLE tag. Wrong! Should have RTFM.

Ok, I did. I just missed that. It clearly says in 2 of the key introductory articles that TABLE tags are one of many on which you are not to use spry:region. More important, the excellent Dynamic Table Tutorial also clearly shows how it's to be done.

You want to wrap the table, in a DIV for instance, and put the spry:region there. If you don't, you don't get an error. You just don't get any of the content you expected to be dynamically generated (which could appear to be a blank page or portion, depending on what you're doing).

Don't mistake spry:repeatchildren for spry:repeat

Similarly, I made another mistake when I copied a line of code to do the repeat, and I used code from an example that used spry:repeatchildren, rather than spry:repeat. Doh!

The Spry Data Set and Dynamic Region Overview says it best in describing the two:

One allows you to repeat an element and all of its content for each row in a given data set (spry:repeat), and another that allows you to repeat all of the children of a given element for each row in a given data set (spry:repeatchildren)

I have lots of other tasty tidbits to share, but they're more general than these related to me trying to write code from scratch.

I-Spry Part 2:Considering Spry as a CFML developer

Note: This blog post is from 2006. Some content may be outdated--though not necessarily. Same with links and subsequent comments from myself or others. Corrections are welcome, in the comments. And I may revise the content as necessary.
In this 2nd part of a series I'm starting on Spry, I've heard or seen various discussions about Spry from some CFML developers, who see the code and/or demos creating dynamic tables and ask, "couldn't I just have done that in CFML?" Well, sure, you could, but think outside the box.

(As suggested in the entry's title, this is part of a series I'm doing on Spry. Be sure to check out the other entries.)

Spry is a client-side tool, first and foremost

Spry is a client-side tool, so on one level it's supposed to appeal to non-CFML developers, who don't have CFML (or PHP, ASP.NET or J2EE) to generate their HTML dynamically.

Spry is about processing XML received

More important, though, even for we CFML developers, you need to think beyond "just creating dynamic tables": the real goal of Spry is to process XML being sent to the client.

Consider, for instance, the situation where you don't control the XML being generated. Perhaps it's coming from an RSS feed or some other xml-generating product on your server (or on some other server, that perhaps you proxy on the spry request's behalf--more on that later, or in the Spry docs).

The point is that you may not then be able to (or want to bother) creating the display in CFML, leaving it instead to Spry to handle.

Spry is about more than "generating dynamic tables"

And Spry can certainly do much more than just create tables. It can create virtually any HTML code based on the data received. Tables are just a simple example most can grasp. We're already starting to see many other and more interesting examples.

Spry is about detecting and responding to page content and source data changes

Still more important, the real value in Spry--and it's true Ajax raison d'ĂȘtre (reason for being) is to do automatic regeneration of content based on changes to the source XML data or other selections on the page, which can include asynchronous communication on the client's behalf back to the server.

That's where things like the dynamic regeneration of regions (which change when the dataset their bound to changes) and master/detail "data references" (where data in one region changes based on selections in another region)really makes things different than "static" HTML you could build "dynamically" in CFML (or other web app platforms).

As I say in my Spry compendium discussed in my previous post, do take the time to learn more from the many available resources, especially the 2 key 30+page documents from Adobe. You'll get a whole new appreciation for what Spry can do for you.

Even so, do look for more posts here as I share some of the other common tips and traps I've hit as I (and others) have explored Spry.


Beyond those comments on looking at Spry as a CFML developer (comparing and contrasting how we might do things one way or the other), there are also a few other comments on why you should be interested in Spry.

Spry is about reducing bandwidth

Those who were around when Flash came out will recall that a big part of its advantages was that it permitted redesign of pages so that rather than transmit the entire page on each "request", the Flash client just requested the data needed to fill a given area of a page.

The same is true with Spry (and Ajax in general). If you can change an interface to retrieve just the needed data (rather than the full weight of an entire HTML page), that can make a big difference in performance and cost savings (hey, someone has to pay for that bandwidth in sending HTML from a server).

Spry is about reducing Javascript complexity

Going back to the first point, all this power comes in a package of tags that dramatically reduce the complexity of the coding needed to enable all these (and more) features. It's possible to create powerful interfaces and interactions with no (or just a tiny amount of) Javascript.

Sure, as we create more advanced interfaces, we may need to understand and use more Javascript. The good news is that both built-in and community-generated demos will help show the way in the near term, and in the long term I'll bet that more work from Adobe in the Spry framework itself will help make still more powerful interfaces just as easy and low in Javascript coding.

Spry is about reducing Browser Interoperability hassles

If you've looked at doing Ajax, you may or may not have had a hassle dealing with whether your code will work on one browser or another. Sure, most Ajax frameworks also try to hide that complexity, but just know that Spry does as well, which is a good thing if you have to deal with supporting different browsers.

There is even an approach to graceful degregation, or what Adobe calls "Progressive Enhancement", discussed at the end of Adobe's great 35-page article, Spry Data Set and Dynamic Region Overview, leveraging something called Hijax methodology.

Admittedly, if the browser doesn't support Javascript at all, that's a separate challenge and a bummer. The challenge of detecting and handling when JS is disabled is not really new to Ajax at all, and I'll leave that to the reader to research or for others (or a later entry here) to elaborate on.

I-Spry Part 1: A compendium of Spry resources for CFML developers

Note: This blog post is from 2006. Some content may be outdated--though not necessarily. Same with links and subsequent comments from myself or others. Corrections are welcome, in the comments. And I may revise the content as necessary.
As the first of a multi-part series I'd like to do on Spry (Adobe's Ajax framework), I've just put together a Spry Resource Compendium. As more and more CFML developers become enamored of Spry, or hear others extolling it, they may benefit from knowing about several available resources to help you get started. Some you may find more readily than others.

(As suggested in the entry's title, this is part of a series I'm doing on Spry. Be sure to check out the other entries.)

I've gathered together several of them, both to save you the work of trying to find them and more important to help you avoid missing key ones, especially ones that focus on CFML-related aspects.

Check it out, at:

http://carehart.org/spry/spry_resources.cfm

I'll try to keep it up to date with new community resources as they're offered, but of course some of the Adobe-provided compendium resources (pointed to on my page) will ultimately become the best place to find resources in the future. For now, I'm just trying to help while there are scattered resources. Drop me a note if you see something I should add.

An interesting short video on Ajax, from Manning (Ajax in Action)

Note: This blog post is from 2006. Some content may be outdated--though not necessarily. Same with links and subsequent comments from myself or others. Corrections are welcome, in the comments. And I may revise the content as necessary.
Saw this offer of free short video intros to Ajax (4 minutes and 20 minutes) and thought it may interest some:

Free Screencast: What is Ajax
Get a taste of what Ajax is all about. Watch the entertaining and informative four minute overview [QT7 8MB] [MP4 12MB] or choose the more detailed demonstration with examples in our twenty-two minute screencast

It's from the folks at Manning Publications, publishers of Ajax in Action.

Solving error connecting to SQL Server from ColdFusion on Localhost

Note: This blog post is from 2006. Some content may be outdated--though not necessarily. Same with links and subsequent comments from myself or others. Corrections are welcome, in the comments. And I may revise the content as necessary.
[Updated a few times since 2006, to correct some minor changes in the tools involved.]

Are you getting the error, "Connection refused" or "Error establishing socket to host and port", trying to connect to a SQL Server database from ColdFusion?

The short answer is:

Open the "SQL Server Configuration Manager" in SQL Server, then choose "SQL Server Network Configuration", and its "Protocols For [yourserver]" option. Open it and ensure that TCP/IP is enabled as a protocol. If not, enable it, and restart SQL Server. For the official MS docs on this, see it discussed in this related topic.

(In later versions, where you don't readily find that Configuration Manager, see my discussion below under "The solution" for other ways to get to that feature.)

And if it is enabled, right-click on that TCP/IP option, choose "properties", then its "IP Addresses" tab, and among the listed features, check if "ipall" (among the last in the list) has the port set to 1433 (or whatever is your SQL Server port), then restart SQL Server. More detail below. If you don't want to enable the "ipall" option, check the other entries to find the IP you're using (which may be 127.0.0.1 or ::1, if using "localhost" for the "server" you're telling CF to connect to), and ensure both that it's "enabled" and that its "tcp port" option is set to 1433. Then restart SQL Server and verify the DSN again.

Note that if it's still "not working" after you make these changes, do make sure you don't see a different error, like "Cannot open database "yourdbname" requested by the login. The login failed." :-) That just means you have a new and different problem to solve, now that this one is resolved. More on that below.

The rest of this entry explains additional details, such as how to find and make that change, what specific errors you get, and how I found the information, in case any of it helps others.

[....Continue Reading....]

Read me on the back page in Fusion Authority Quarterly Update

Note: This blog post is from 2006. Some content may be outdated--though not necessarily. Same with links and subsequent comments from myself or others. Corrections are welcome, in the comments. And I may revise the content as necessary.
As others have pointed out, the fine folks from Fusion Authority have come out with a new "Quarterly Update" magazine, with lots of content and few ads. I was delighted when they asked me to contribute a tips column on the back page. This quarter, I discuss 4 ways to read text files in CFML--there's much more than just CFFILE.

The mag was offered to all attendees at the conference and is also available as a subscription (paper only) at http://www.fusionauthority.com/quarterly/.

IBATIS as a possible new approach to object-relational mapping for CFML?

Note: This blog post is from 2006. Some content may be outdated--though not necessarily. Same with links and subsequent comments from myself or others. Corrections are welcome, in the comments. And I may revise the content as necessary.
I'd like to put out for consideration by the CFML community a possible new approach for object-relational mapping (ORM), using an existing Apache project called IBATIS as a model. I'm wondering if someone may want to consider implementing a CFML version of it for a new ORM approach in CFML.

IBATIS, at http://ibatis.apache.org/ is an alternative ORM approach based on a concept of SQL Maps, which in essence are simply SQL statements stored in XML files with a well-defined API for mapping and manipulating those in your app. The approach does not generate SQL for you, but rather is intended to serve as a means to segregate to XML files--and manage via an API--the SQL that may already exist substantially for existing apps or for new apps that may simply require some hand-coding of SQL. (The last sentence added after some comments suggest that this point made later in the post was missed.)

The benefit is that since CFML folks are already knee deep in SQL, it brings a measure of architecture without completely detaching them from the SQL they know and love (or at least tolerate).

If that sounds counter to other ORM approaches, which often generate the SQL automatically and/or intentionally hide it from you, that's because it is quite different. I'll grant that there are many who would benefit from having an architecture remove SQL from their control. It's just that this seems an alternative worth considering.

I certainly don't mean to knock at all the other CFML-based ORM implementations that exist already (such as Arf, ObjectBreeze, Transfer, and Reactor). Each approach has its place and pros/cons. As the other CFML-based ORM frameworks tend to be based on existing approaches from other platforms, I'm merely pointing out this alternative as a possibly useful model.

I'm also not offering here my own new CFML-based implementation based on IBATIS. But note that there are currently implementations for Java and .NET at the Apache site, so it shouldn't be tough for someone to leverage the Java implementation in CFML.

It strikes me that the IBATIS approach may be closer to the way fuseboxers and others segregate their queries into their own CFML file. Perhaps this approach of storing them in an XML file instead and using an API to access the results would offer a better though still somewhat familiar approach to abstracting queries.

I was sharing the idea with Sean Corfield at CFUnited last night, and he was intrigued. After I sat in on his excellent presentation on objects and persistence, we discussed it again and he had started looking into it overnight. Perhaps it could make it into FB 6? :-)

I'm hoping someone may want to take the ball and run with it. If you're intrigued, considering discussing it with Sean or take it on yourself, or just continue the conversation. Hope it proves helpful.

Some personal trivia about the CFUnited location, Bethesda/Rockville

Note: This blog post is from 2006. Some content may be outdated--though not necessarily. Same with links and subsequent comments from myself or others. Corrections are welcome, in the comments. And I may revise the content as necessary.
In my last post, I referred to CFUnited as being in DC. I said that simply because most people don't know what you mean if you say Bethesda, Maryland. I do, because I was born there, 6/4/62, at Suburban Hospital on Old Georgetown Road just down the street a couple miles. :-)

That reminiscing got me thinking some thoughts that others might enjoy on the eve of CFUnited.

First, I'll say that I used to buy burgers at the "Gino's" that was near the spot where the conference hotel now stands. Here's a trivia question for my fellow long-time DC folks: do you know where Gino's (a burger chain now long gone) got it's name? I'm told it was Gino Marchetti from the Baltimore Colts. Wikipedia backs me up. :-)

Here's another: the large open air shopping center behind the hotel on Rockville Pike used to house a large Korvette's department store. Ever wonder about that name? I was told it was formed by some former KORean VETerans. :-)

I grew up skating at Congressional Roller Rink, which was also just up the road a mile (now long gone) in Rockville. It was the center of our lives for many of us, and a great, safe place to grow up. Well, we'd hop the train back and forth to either Rockville Mall or White Flint (which had just opened in the 70's), and I suppose that wasn't too safe. But we could find great old beer cans on the tracks--anyone else ever get into that collecting? Still have mine. I recently started a site to connect with others who may have skated/grown up at the rink, http://congressionalrollerrink.com. :-)

Moving forward a couple decades, those who have attended the Maryland CFUGs, where I used to speak often before moving to Atlanta, will know I've told the story that my ancestors farmed property just a mile away from the conference facility, across the street from where we used to hold the Maryland CFUGs on Parklawn Drive. In the 50's they sold the land and soon thereafter arose the big black Parklawn building.

One last bit of trivia, that few could answer: where and when was the first place I spoke to a CFUG audience? It wasn't the DC CFUG, run by FigLeaf, where I spoke often while I worked there in 1999-2000. It was the Maryland CFUG, back in Feb 1998. Sadly, the records of those early meetings are missing from the archives, but I have it at my old Systemanage site list of past presentations.

OK: one more piece of personal CFUnited trivia. Last year it was determined that only one person (other than Michael) had attended all the CFUnited events, back to when they were first called CFUN and held at the NIH facility. Um, guess who? :-)

If you have other fun CFUN/CFUnited memories or trivia, please do share.

/charlie

More Entries

Copyright ©2024 Charlie Arehart
Carehart Logo
BlogCFC was created by Raymond Camden. This blog is running version 5.005.
(Want to validate the html in this page?)

Managed Hosting Services provided by
Managed Dedicated Hosting