Sunday, December 31, 2006

Happy 2007

Just an end of year note to wish you and yours a happy New Year. May you ring in 2007 with the people who are important to you.

Oh and if anyone received a Tivo this year (what took you so long?) feel free to reference tjordahl at adobe.com when you sign up and send some Tivo reward points my way. I am saving up for the Series 3 (85,000 points) and I only need 80,000 points to go. :-) The good news is that each referral is 5,000 points.

But seriously, 2007 is going to be a great year for ColdFusion. The team has been rolling toward our first Scorpio Beta with a killer set of features that we hope will continue to make our customers even more amazingly productive with our stuff. We think Scorpio is going to have something for everyone, from language enhancements to major new features that we hope will rock your world! Stay tuned!

Friday, December 01, 2006

ColdFusion MX 7.0.2 Cumulative Hot Fix 1

Get your hot fresh bits. ColdFusion MX 7.0.2 Cumulative Hot Fix 1 is now available from the Adobe support web site.

There are also a few other separate updates available from that page, including an update to a new Verity patch level, an update to the cfform Java applet certificate, updated DataDirect JDBC drivers (only if you need it!) and a Flash Remoting ("classic", not the 7.0.2 "update" for AS3) fix for returning structures to Flash.

Enjoy!

Wednesday, October 11, 2006

MAX is coming up soon

Just wanted to remind everyone that Adobe MAX 2006 is coming up on Oct 24-26, which is just under two weeks away. Registration ends on Oct 16 (onsite registration will still be available). ColdFusion users should definitely attend this year as a) its in Las Vegas and b) My session on Flex FDS and ColdFusion integration is a must see :-)

The keynote sessions promise to be pretty interesting this year. Day 1 will cover the "Adobe Engagement Platform", which should be something that any CF developer should probably understand. Not because ColdFusion is at the center of it (think Flash and PDF) but because Adobe will be talking about this a lot in the next year and it will help the CF team if you know what it is when we start talking about how CF fits in to all the pretty boxes. :-)

The Day 2 keynote is going to have lots of Adobe mobile info (yes, I sometimes get tired of hearing about flash on phones too) , but also the MAX awards, which I think are always neat.

The Day 3 keynote will be the sneaks session we have had in many past DevCon/MAX shows. The ColdFusion team has some stuff we want to show at this one. Can't say much more about that, but you can bet that the other groups in Adobe will have some real cool stuff to show too.

I am presenting my session twice, Tuesday at 4:15pm and Wednesday at 10:30am. I will also be manning the Adobe booth on Monday afternoon and Tuesday morning, plus I am sure I will be loitering around at other times too. You wont be able to miss me or the other members of the CF team as we will be wearing yellow bowling shirts (yikes!) when we are not wearing the official Adobe uniform for MAX.

Hope to see you all there!

Wednesday, September 13, 2006

ColdFusion Email Validation, IsValid(), And CFMail Errors

Ben Nadel posted a comparison of the differences in behavior between the IsValid() function for Email addresses in ColdFusion 7 and the addresses that the CFMail tag will accept.

I posted this as a comment on his blog, but thought it was interesting enought that others might want to know what is going on.

The IsValid() function uses the following regular expression to determine if the email is valid:
"^[a-zA-Z_0-9-'\+~]+(\.[a-zA-Z_0-9-'\+~]+)*@([a-zA-Z_0-9-]+\.)+[a-zA-Z]{2,7}$"

The CFMail tag uses the Sun Java class javax.mail.internet.InternetAddress parse() function. Since the implementation uses JavaMail, this is how we generate the InternetAddress objects that we pass in for the addresses (to, from, cc, etc).

The "strict" attribute is turned on. The JavaDoc says of this:

"Parse the given sequence of addresses into InternetAddress objects. If strict is false, simple email addresses separated by spaces are also allowed. If strict is true, many (but not all) of the RFC822 syntax rules are enforced. In particular, even if strict is true, addresses composed of simple names (with no "@domain" part) are allowed. Such "illegal" addresses are not uncommon in real messages.

Non-strict parsing is typically used when parsing a list of mail addresses entered by a human. Strict parsing is typically used when parsing address headers in mail messages"

See the InternetAddress JavaDoc at http://java.sun.com/products/javamail/javadocs/javax/mail/internet/InternetAddress.html

In general I think that the more strict IsValid() behavior is a good thing, and importantly it matches the client side validators used for forms in the browser. This is what it is intended to do (match client and server behavior).

Tuesday, August 08, 2006

Flex 2 and ColdFusion seminars

Just wanted to note that Adobe is offering some seminars across the United States featuring Ben Forta talking about Adobe Flex 2 and Macromedia ColdFusion MX 7. Its worth checking out if you leave near one of the (currently four) cities Ben is coming to visit.

On a related note, I am going to be giving a detailed session at MAX in October (which I am working on today!) about the CF and FDS integration we released in ColdFusion 7.0.2.

Wednesday, July 12, 2006

Ashwin blogs about the ColdFusion Template Cache

Ashwin, a member of the CF team, has just posted a revealing entry in his Stake Five blog about Tangling with the Template Cache. Check it out for information about one of the two most important settings in the ColdFusion administrator (the other is Simultaneous Requests) works.

Friday, July 07, 2006

ColdFusion 7.0.2 (Mystic) Released

ColdFusion 7.0.2 has been released (I am late, we announced it at CFUnited on June 28, 2006).

Find the release notes here: http://www.adobe.com/support/documentation/en/coldfusion/mx702/cf702_releasenotes.html

While there is a link in the release notes, I wanted to explicitly spread the word on where to find the documentation for the new Flex 2 integration features we have added. The new chapters can be found at
http://www.adobe.com/go/cfmx702docs


In addition there is a ton of new content in the Adobe Developers Center.

Lots of great content - Enjoy!

Thursday, June 29, 2006

Another ColdFusion team members blog

On of the newer members of the ColdFusion team, Ashwin Mathew, has started up a blog about ColdFusion among other things. Ashwin has posted a great article on caching and plans to follow it up with some interesting posts about how CF does its internal caching of things like template.

Ashwin is also here at CFUnited this week. Check it out.

Thursday, June 22, 2006

CFUnited next week

Since I am on a blogging roll this week, I wanted to note that I and many other members of the ColdFusion team will be attending CFUnited next week.

Even though I am really looking forward to Adobe MAX in Las Vegas this fall (probably because I love BlackJack and Vegas), CFUnited is where "my peeps" are at since it is focused almost 100% on ColdFusion. Through some quirk of fate, I am not giving a session this year (I guess I am not famous enough :-). But I will be hanging at the Adobe booth for large chunks of time and attending as many sessions as I can. I really find it fascinating to hear people explain features of CF that I have had a hand in designing. It is almost like a game of telephone - where someone whispers a message to another person on down the line, then you compare what the last person in the line says to the original message. The result is always surprising. Sometimes the message gets through, sometimes it gets really garbled. :-) But in every case it allows me to get a better view of the problems our customers are solving (or not solving) with CF so that next time I can get it closer to right.

This is your chance to harass me about how CFCs should be "just like" Java objects, why CFML should be strongly typed, why we should rewrite the file browser in the CF administrator to not use Java, why you can't possibly use CF anymore because we don't have {cfimap,cfimage,etc, etc}. I will have my laptop and access to source control, so maybe you can convince me to add/fix/remove something that you have always wanted in Scoprio right on the spot! :-)

See you there!





Wednesday, June 21, 2006

A Better Way to Make a String Array

I was jumping through some hoops to generate a true Java String array in CFML yesterday to pass in to a web service API. Today, while talking to some of the guys on the CF team it came up that there is a really simple way to get an array of Strings in CFML: Use the Java String split() API!

Code before:
string = CreateObject("java", "java.lang.String");
array = CreateObject("java", "java.lang.reflect.Array");
cookies = array.newInstance(string.getClass(), 3);
array.set(cookies, 0, "x=1");
array.set(cookies, 1, "x=2");
array.set(cookies, 2, "x=3");

Code After:
s = "x=1,x=2,x=3";
cookies = s.split(",");
I would say the second way is much easier. It is using a regular expression, so it isn't going to go as fast as the first code sample, but for something like this I would not worry about it at all.

How to get web service response cookies

So yesterday I wrote about how to get the Axis engine that underlies the ColdFusion web services to send cookies in the request. The follow on question asked shortly after I posted that was how do I get cookies sent to me from (say) an initial login request to the web service.

Here is how to do that:

ws = CreateObject("webservice", ...);
ws.setMaintainSession(true); // required so axis will do cookies
ret = ws.log_in_or_something();
...
// Get cookies returned from server (if any)
call = ws._getCall();
ctx = call.getMessageContext();
server_cookies = ctx.getProperty("Cookie");
Getting the cookies out of the Axis MessageContext will return either a single string if there is one cookie, or an array of Strings if there are more than one. One thing to watch out for is if there are not any cookies returned from the server, the return value will be (Java) null, so you will need to used isDefined() on that variable before using it. The other thing to watch out for is that the MessageContext property 'Cookie' will keep the values that you have set in to it if you set cookies before makeing a call. They will only get overwritten if the server send something back.

Tuesday, June 20, 2006

How to set Cookies in ColdFusion SOAP requests

I spent some time today working with a customer who is using a web service that requires its users to set HTTP cookies in their SOAP requests. First off, I think this is just wrong as this is what SOAP headers are used for and ColdFusion MX 7 (6.1 too) can easily set SOAP headers in both requests and responses.

In any case, Apache Axis can include HTTP cookies in the requests it sends out and since ColdFusion uses Axis as its implementation engine, you can do it in CFML also.

First, how would you set a cookie (or cookies) in Java? Here is some sample Java code:

    mystub._setProperty(
HTTPConstants.HEADER_COOKIE,
new String[]{"myCookie1=hello", "myCookie2=goodbye"});

This calls the "_setProperty" function on the Stub object, passing it a string ("Cookie") and an array of strings, which are the cookies to set. It turns out that the Axis code will look at the second argument and if it is a single String, it will set that as a cookie. If it is a String array, then it will treat each string in the array as a different cookie header.

So, how do we duplicate this in CFML?

First, realize that when you create a "webservice" object in CFML, this can be treated as the org.apache.axis.client.Stub class using the CF/Java interop. So in the case of setting a single cookie, we have no problems:


ws = CreateObject("webservice", "path-to-wsdl");
ws._setProperty("Cookie", "myCookie1=hello");

But this doesn't work! Why not? Well for those of you following along in the Apache Axis source tree, you will notice that the org.apache.axis.transport.http.HTTPSender.java class has this code in it (around line 260):

// don't forget the cookies!
// mmm... cookies
if (msgContext.getMaintainSession()) {
fillHeaders(msgContext, HTTPConstants.HEADER_COOKIE, otherHeaders);
fillHeaders(msgContext, HTTPConstants.HEADER_COOKIE2, otherHeaders);
}

So we need one more thing, we have to turn on the "maintain session" switch in the message context. This turns out to be simple to do as there is an API on the Stub to do just that:

ws.setMaintainSession(true); // required so axis will do cookies

Great, we add that and we can set one cookie for any web service operation we invoke. But what if we want to set more than one (this to-be-nameless service requires three!)?

Well, we need to create an array of Java Strings to pass in to _setProperty(). What happens if we try and use a CFML array? Well, usually CF is really good about taking its (mostly) typeless things and converting them to particular java types. But in this case the API signature for _setProperty is this:

public void _setProperty(String name, Object value);

So CF happily passes the CFML Array in to this API as an object. But deep down in the Axis code (HTTPSender.java, line 534 or so), it tries to treat this object either as a string array (String[]) or a String. Neither of which works in this case. You next thought might be to use the JavaCast() CFML function, as this is one of the cases that it is designed for. But unfortunately it only handles scalar (simple) types (yes, we need to enhance that). What next?

Well, in CFML you can create an Java object that you want using CreateObject. It just so happens that the java.lang.reflect.Array class has functions that will create arrays. So we can use the newInstance() function to allocate an array. This function takes in a Class object and the number of elements in the array.

string = CreateObject("java", "java.lang.String");
array = CreateObject("java", "java.lang.reflect.Array");
cookies = array.newInstance(string.getClass(), 3);

This creates a 3 element String array. One bug that this uncovers is that you can not treat this array the same as a CFML array. For instance you can not assign cookies[1] = "x=1" because ColdFusion will report a problem with casting "coldfusion.runtime.Cast$1", which is a really bad error message that makes sense if you could read the source code like I did, but doesn't help at all. Suffice to say that we are doing the wrong thing with a Java array when trying to set a value in that array. So what can we do? The Java Array class comes to the rescue again as we see that it has a set() API that takes an array, the index and the value you want to set. So we can call it like this:

array.set(cookies, 0, "x=1");
array.set(cookies, 1, "x=2");
array.set(cookies, 2, "x=3");

Watch out for the zero (0) indexed Java array, which differs from the one (1) indexed arrays in CFML.

We are then all set, we can use our cookies array as an argument to _setProperty and since we know it is a String[] (and CF wont change that) it will get down to the Axis HTTP class and be sent out in the HTTP request.

Here is the complete cfscript code:

// Create the array for cookies
string = CreateObject("java", "java.lang.String");
array = CreateObject("java", "java.lang.reflect.Array");
cookies = array.newInstance(string.getClass(), 3);
// set the cookie values
array.set(cookies, 0, "cookie1=one");
array.set(cookies, 1, "cookie2=two");
array.set(cookies, 2, "cookie3=three");

ws = CreateObject("webservice", "http://localhost:8500/test.cfc?WSDL");
ws.setMaintainSession(true); // required so axis will do cookies
ws._setProperty("Cookie", cookies);

// invoke an operation
ret = ws.echo("hi");

Thursday, March 23, 2006

Excellent Use of ColdFusion IM Gateway

Marc Garrett has posted an excellent article about leveraging the ColdFusion Event Gateways in a custom application to add real time notification using Google Talk and iChat.
Read it in his posting: ColdFusion Event Gateways: Building an eCommerce Bot for iChat and Google Talk

This is one of the use cases that we had in mind when working on the IM Gateways for ColdFusion MX 7. It's nice to see how smoothly this worked for Marc.

Tuesday, March 21, 2006

Mystic public Beta 2 now available

The public Beta 2 of the ColdFusion/Flex Connectivity kit is now available over on the Adobe (f.k.a Macromedia) Labs site. Flex 2.0 Beta 2 is has also been released.

This beta has some great stuff in it. First, if you have seen any information about Flex 2 you have probably heard about the Data Services feature (not to be confused with the product name, which has been changed to Flex Data Services). This provides you with some really slick help in managing data on the client and server. For instance, if one client updates a data table all of the other active clients are notified (using the Flex Messaging feature) about the change and can update real time. I encourage you to read about this in the Flex materials available on the labs site.

New in Mystic Beta 2 is that you can now write the back end of this stuff with ColdFusion Components instead of Java. This allows you to use the RAD environment of CFML along with your Flex applications.

We have also updated the Flash Remoting (formerly the ColdFusion Adapter) to allow you to invoke CFCs from Flex/ActionScript3 applications. And the Flex messaging Gateway, which supports publishing and subscribing to Flex destinations from ColdFusion, has been refreshed.

Also new in Beta 2 are some really sweet Flex Builder/Eclipse wizards that make it trivial to create either Active Record or Bean/DAO CFCs from an existing database table, or even generate an entire set of CFCs to act as the back end to a Data Service application (these are called Assembler CFCs). To compliment these wizards, this is the first public beta release of RDS support for Eclipse. This includes both file and database table browsing. Combined with CFEclipse, these additions to Flex Builder make it a really nice IDE for creating CF and Flex rich internet applications.

Check it out!

Wednesday, March 08, 2006

ColdFusion MX 7.0.1 Cumulative Hot Fix # 2

ColdFusion MX 7.0.1 Cumulative Hot Fix 2 has been made available on the ColdFusion support site. This fixes a handful of stuff that you may care about. It includes some Verity fixes, a cfdocument issue, and some CFC/web service issues. See the tech note for details.

Wednesday, February 22, 2006

Mike Nimer takes his licks

Mike Nimer takes his lumps like a man over on his Blog. I would hate to have a whole magazine devoted to some of the CF 3.1 C++ code I wrote!

Compiling Custom Event Gateways For Dummies

This is old news in the blogsphere (and you probably read about it on Sean Corfields blog ages ago) but Rick Root has a very useful article on Compiling Custom Event Gateways from a non-Java developers point of view.

Speaking at cf.Objective() - March 11 & 12, 2006, Minneapolis, MN

I have just booked my travel and wanted to post the fact that I will be presenting at
cf.Objective() - March 11 & 12, 2006 in Minneapolis, MN. I believe I will be doing a general session giving a preview of Mystic, the latest update to ColdFusion MX 7 now in Beta that will give CF developers some really great stuff to take advantage of Flex 2.

I am stepping in for Tim Buntel, who has (sadly) left Adobe to move on to other opportunities.

I have also agreed to whip up a session on Web Services and Java. I will go in to some detail on how CFMX uses the Apache Axis WSDL2Java tool to create code to consume Web Services and hopefully give people insight on how to construct CFML data structures that can be used as argument to services that require complex types as inputs.

So check out the conference detail on the web site. The list of speakers and session topics look really good and this event is sure to be great for hard core CFML developers.

Wednesday, February 01, 2006

Adobe releases Flex 2.0 Beta 1 on Adobe labs

Flex 2.0 released a public Beta on Adobe Labs yesteraday. In addition to refreshing Flex Builder 2.0 and the Flex framework, this Beta also includes the Flex Enterprise Services (FES), which is the service piece of Flex 2.

Along with this is the "ColdFusion/Flex Connectivity" beta, which includes two interesting pieces for ColdFusion developers

1. The Flash Remoting Update. This is an update to the Alpha released last year (formerly called "the CF Adapter") that allows you to use the new Flash Remoting functionality with Flex Builder 2.0 and CFMX. The sweet thing here is that you can map CFC objects on the server to ActionScript objects on the client seemlessly. These are called "Value Objects".

2. The Flex Messaging Gateway. This is the piece that I wrote that uses the Flex 2.0 Messaging system to allow ColdFusion MX 7 to Publish/Subscribe messages to/from a flex application. I think this is pretty cool - you can use SendGatewayMessage() to send a message that multiple Flex clients will receive. And vise-versa.

Anyway, check it out up on Labs and let me know whay you think!

Thursday, January 19, 2006

Adobe and CFUnited

CFUnited is coming up (OK it's at the end of June) but Adobe is now the platinum sponsor of this ColdFusion focused conference.

The ColdFusion team showed up last year in force and while we haven't set plans yets, you can probably count on us being there again since we are a sponsor. Perhaps we will be sporting some new Adobe branding clothing. :-)

See you there!