July 10, 2006
DB2 stores information about database objects in what it calls the System Catalog. There are a number of views in the system catalog you can use to obtain metadata about your database such as columns, key relationships, schemas, stored procs, etc.
Today, I was working on a report where I wanted to display statistics about a number of staging files we use in our applications. I wanted to list things like number of records, number of columns, column names, etc. Things like the number of columns were easy to do just by selecting count(*) from the source table. To get the number of columns, though, I didn't want to use a hack like selecting a single record and getting the column list from that. What I wanted to do was query the system catalog. Unlike SQL Server, Oracle, and just about every other DB platform out there, documentation for DB2/400 is rather scarce.
After a lot of googling, I found a DB2/400 reference that had the information on the system catalog I needed. For those interested, the full documentation set can be found here. As IBM documentation has a tendency to disappear, here's the SYSIBM.SQLCOLUMNS library/view I used to query column information from the system catalog:
SELECT count(*) as totalRows
WHERE TABLE_NAME = 'yourTable'
If you want to get a list of all columns, along with a lot of additional info about each column, just do a SELECT * instead of the count.
There are several other useful SQL views you can use:
SQLCOLPRIVILEGES, SQLFOREIGNKEYS, SQLPRIMARYKEYS, SQLPROCEDURECOLS, SQLPROCEDURES, SQLSCHEMAS, SQLSPECIALCOLUMNS, SQLSTATISTICS, SQLTABLEPRIVILEGES, SQLTABLES, SQLTYPEINFO, SQLUDTS
July 6, 2006
Ok, that was fast. The CFCDev mailing list is now working correctly. It looks like the spam filtering was ratched up a little too tightly and was blocking some valid messages. We'll be addressing this over the next few days as we find the right balance between valid messages and spam filtering.
July 6, 2006
Just a quick note that the CFCDev list is currently down due to an issue implementing our new Spam filtering system. We're currently working on the issue and hope to have it resolved shortly.
June 30, 2006
Sitting in on the Spry presentation with Kelly Brown right now. He starts off by asking who attended Steve's CFAjax presentation, then making the point that Spry is (in his opinion) much easier to use. Next up is a general intro to Ajax.
The goals of Spry are open access, easy to use, and innovation enablement. Spry capabilities include loading and displaying data, filtering data using XPath, UI widgets, and visual effects. It's currently in beta, with new features still being onboarded.
Looping is also available, similar to how it's done in ColdFusion.
Spry also has a mechanism for handling master/detail records. You can select an item from a list and have more information about that item displayed.
Kelly is moving along kinda slow, and so far the examples haven't been too dynamic. He's displaying data, but we aren't seeing much as far as dynamic data goes. So far, it doesn't look any different than just pulling data using CF and displaying on the page.
I've taken a look at one of the previous beta versions of Spry, and I do have to admit that it does seem simple to use. I still haven't gotten a good feel for everything Spry can do, and unfortunately, I'm leaving this session not much further ahead than where I started. It's nothing against Kelly - he seems pretty knowledgeable about Spry - it's just that I was expecting a slightly faster pace and a little more depth out of the presentation.
June 30, 2006
Besides CFAJax, there's also ajaxCFC (by Rob Gonda). It uses a slightly different approach. There are also several non-CF specific Ajax frameworks which can be used.
Steve's moving into some simple examples now. It's a speaker search where you start typing a last name in a form field and Ajax is used to send the info as you type, updating the form field with possible matches. This is basically the way Google Suggest works.
Pros of the templating system include returning HTML - there's no hard coded DOM work. It's also, in Steve's words "very, very, very easy". The cons are that it feels a bit dirty, and may rub purists the wrong way. Again, there's a cost benefits analysis to be done. He shows the simple example again, this time using the templating system.
Steve's mentioning upcoming Ajax trends include Ajax/Flex integration (they actually complement each other) as well as mobile Ajax.
Lots and lots of "how do I do..." questions coming from the audience. There's obviously a lot of interest in this topic. Steve's doing a good job of answering them. This presentation could definitely span multiple sessions.
Steve looks to be wrapping up with an example of how to integrate CFAjax within the Mach-II framework. It's very similar in ModelGlue as well. He's showing the demonstration from within an application his company created called RecruitWeb. It's a pretty slick application for use by athletic recruiting departments. The application is completely written in ColdFusion using Mach-II as the framework and AjaxCFC. If you are interested in the mechanics of the integration, I believe Steve is making the techniques available on his company's website, I'm sure he'd be glad to give a fuller explanation.
June 29, 2006
Ron West is discussing advanced web services in ColdFusion. He's starting out by discussing some of the current problems with web services: Security, simple examples (think weather, stocks, etc), document vs. rpc.
ColdFusion uses Apache AXIS under the covers. It basically wraps the class org.apache.axis.client.stub. There are lots of useful methods you can call directly on the class. Here are a few:
WSDL isn't necessarily dynamic. In fact, you can create static WSDL files that correspond to CFC's on your system. You can also modify the static WSDL files. This lets you do things like manage endpoints. Endpoints are locations (URI) for accessing a web service. They can change during the web service call. This allows you to do things like create a simple authentication service for web services. Ron shows an example where you call one login webservice and after authenticating, it returns back the URI to use for the authenticated service. It's very simple, but it does add a layer of additional security (albeit very basic security).
SOAP headers allow you to pass additional information along to/from web services. Pre MX 7, working with headers was a real pain. In MX 7, two new functions made working with headers easier: getSOAPRequestHeader() and addSOAPRequestHeader(). SOAP headers are passed as XML. On the ColdFusion side, you can choose to work with the SOAP headers as XML or have them split out into name/value pairs.
Web services actually do support persistence (well, they support persistence of the objects being passed, but the connection itself is stateless). You can do them at the client level (via scopes in CF such as applicatoin and session) as well as the service level. AXIS has SESSION_MAINTAIN_PROPERTY as well as cookie support.
Ron then went on to show some integration examples, including one that integrated Salesforce.com with a ColdFusion application (CommonSpot CMS) by using salesforce.com's web services API (it has a 3500 line WSDL!).
Overall, a very good presentation on some of the advanced ways to work with web services in ColdFusion.
June 29, 2006
Sitting in on Dave Ross's Inversion of Control (ColdSpring) presentation right now. Dave's laying the groundwork for the "what & why" of ColdSpring. For background, it's a framework, but not one like ModelGlue, Fusebox, Mach-II, etc. It's more like a container for your application's model. It doesn't handle HTTP requests. It's based off of the Java Spring framework, but it's not a one-for-one port. It attempts to solve the same problems, though.
ColdSpring implements a flexible model, where components use each other (one component depends on another to do work), as opposed to one component creating and configuring another. This is called a dependency, with the two components being collaborators. As an IoC container, ColdSpring injects one component into another. Components don't have to create and configure each other - they just use each other. This also makes the actual implementation unimportant as you are now programming to an interface.
Polymorphism - you can swap out one implementation of a component for another and collaborators don't know the difference.
ColdSpring works like this:
- Create an xml file that defines the components and their configs
- Refer to the content as bean definitions of bean defs - bean is interchangeable with component
- Create a ColdSpring BeanFactory and then pass in your bean definitions
How does ColdSpring get used in a real app:
- When app starts, BeanFactory is created and supplied with bean defs
- BeanFactory is placed in a persistent scope (application) so that the beans are singletons
- In an MVC app, the controller obtains the component(s) it needs from the BeanFactory
- ColdSpring is not usually involved with the creation of transient or value objects because that requires knowledge of the framework by other components. The main idea here is that your model shouldn't know it's being managed by ColdSpring.
BeanFactory can also do auto-wiring. Lets ColdSpring automatically figure out which components should be injected where by looking at the method signatures of the defined components and matching with bean definitions. There are pros and cons to auto-wiring. Pros are less typing and less xml. Cons are having to keep better track of what's going on.
ColdSpring AOP (aspect oriented programming). It allows you to apply a piece of code across the rest of your codebase in logical places - such as before or after a method call or when an exception is thrown. AOP is often used in logging and security, but it isn't limited to that. It also works well for managing transactions and workflow. ColdSpring AOP can also be used to expose functionality to services such as Flash Remoting without having to create a facade. Chris Scott programmed the AOP piece of ColdSpring.
ModelGlue 2.0 uses ColdSpring as the default IoC container. It's used by the framework itself and is also exposed so you can use it.
June 29, 2006
If you make regular use of scheduled tasks in ColdFusion, you'll be happy to know that a nagging, intermittnet bug has been fixed. Bug #61272 had to do with the ColdFusion schedluer firing off scheduled tasks twice after a server reboot. You can download ColdFusion 7.0.2, which contains the fix.
Personally, I only ran into this issue once on one of my production servers, but it was a big problem when it hit. We have over 600 scheduled tasks on our server which generate customer reports which are emailed out on a daily basis. Customers were irritated with receiving two copies of each report, and the additional load on our server was not desirable either.
At the time, we "fixed" the problem by deleting all of the tasks and recreating them. We scripted the bulk delete/recreate, but it was still a bit of a pain. After that, we haven't run into the issue again. I've read other reports from users with the same problem, so it's good to know a permanent fix is now available.
June 26, 2006
June 5, 2006
Other than a blog post by Simon Horwith, I haven't seen much chatter regarding the new CFGURU blog. The CFGURU blog is a companion site to the private CFGURU mailing list. The site is moderated by Shlomy Gantz, with a charter to share useful discussions from the mailing list with the ColdFusion community at large.
There are currently only a handful of posts on the site, but you can expect a lot more great content as Shlomy compiles and publishes posts from the list.