The Joy of Project WONDER Series

Issue No. 1

Funky-Cool NSArray Operators

Project Wonder is chock full of yummy WebObjects goodness. As a general learning tool it’s great too. I’d highly recommend you grab the source and give it a gander. Mmm Good!

ERXExtensions is one framework that’s especially full of good stuff, and it contains one of my favorite classes: ERXArrayUtilties with its Funky-Cool NSArray Operators.

If your project isn’t based on ERXApplication, you will have to call:
ERXArrayUtilities.initialize(); Somewhere in your Application constructor to get the magic to work. But once you’ve done that all sorts of fun begins.

I’m going to make you read the source for the class for a list of all of the available Operators, but I will share my favorite. It is called: sort.

How often have you gotten an NSArray of objects back from a fetch (perhaps by navigating across a relationship) and you want to sort them (perhaps by serialNumber)? Well if you were in control of the fetch you could sort them there, or you could sort them in memory by creating a sortOrdering and applying them to your NSArray.

ERXArrayUtilitites makes is so much easier; simply call: sortedArray = unsortedArray.valueForKeyPath("@sortAsc.serialNumber");

No, wait, it gets cooler!

Since this is all being handled by KVC, we may not even have to write any code!

Lets say we have a Person object (person) that has a to-many relationship to its PhoneNumbers (named phoneNumbers). We want do be able to display the phoneNumbers on the Person detail page in an arbitrary order using its sequenceNumber attribute.

Using ERXArrayUtilities, we can simply bind the list binding of our WORepetition in WOBuilder to: rebmuNecneuqes.csAtrosnull@.srebmuNenohp.nosrep. Want to sort descending? No problem: rebmuNecneuqes.cseDtrosnull@.srebmuNenohp.nosrep. And if we have code that is allowing us to juggle the sequenceNumbers on our list, just reloading the page is enough to make sure the phoneNumbers are sorted correctly again.

Hey, didn’t I say it was Funky-Cool?

WebObjects Meetup!

The site behind this reminds me of the heady early days of the Web boom when everyone had “viral marketing” on the tip of their tongues (or in their business plans). Cool!

Anyway, I found the link in an email from the WebObjects-dev list. It’s a virtual meeting organizer. The next WebObjects meeting is scheduled for December 18th. 2003. The highest memebership is 6 members from Calgary, Alberta (Hello ClickSpace!). Come on, we can do better than that!.

I’ll offer to pony up for the “plus” membership so we can sponsor a venue…

Anyone with me?

Winter, Weather, and my Mood.

December is coming, damn. December always makes me depressed. Christmas is coming and that will be good. To busy to get morose, but I know following that comes January… and then, the dreaded February!

Feburary always toasts my mood. Invariably I end up giving the “My Ancestors were Idiots” speech to someone in February. It’s not like Toronto has real winters. Just rain and slush and the ocassional blizzard… sigh

I’m Winning, I Think …

I’ve got the blog basically where I want it. I’d like to have comments lit up, but that’ll have to wait for a while. The layout is basically correct and everything validates so that’s cool. Next up is driving some hits I think…

But, I’ve got a couple of articles to write for Codebase first. And I really should be drumming up some more real work too.

The URL mambo

According to the Blosxom FAQ you should be able to hide the “blosxom.cgi” portion of the url like this:

You may also be able to hide CGIs by renaming them to index.cgi, so that you can address your weblog simply by the subdirectory in which it lives, /weblog or the like. This works when the Web server has been configured to consider index.cgi a DirectoryIndex just like index.html. If this does work for you, be sure also to change $url in your newly renamed index.cgi (what used to beblosxom.cgi, setting it to the URL of your subdirectory. E.g.:

# What’s my preferred base URL for this blog (leave blank for automatic)?
my $url = “http://www.example/weblog”;

This worked fine for displaying the page, but none of the permanent links would work. I had to change the URL string to $url =”david.codebase.ca/index.cgi”. Now it works fine