Welcome to OGNL!

OGNL 1.0.4, by Drew Davidson and Luke Blanshard, is now available, and OGNL now has it's own web site!

The pure-Java Object Graph Navigation Language is an extremely evolved version of KVC (Key Value Coding), a pattern used extensively in WebObjects to make connections between the view objects and controller objects, and often model objects because controllers often have acccessors that return model objects.

An example of KVC a WOD file (WO Declaration file):

UserManagerLastName: WOTextField {
    value = user.department.manager.lastName;
}

KVC uses reflection to traverse the object graph starting at "user" (which it gets using KVC on the component's controller) by finding methods like "department" or "getDepartment", then "manager" or "getManager", then finally "fullName" or "getFullName". (It will also look for _key or _getKey, or a field called key or _key, but you get the picture).

When the page is displayed, the value of the key-path bound to the value binding will be inserted in the VALUE attribute of the INPUT tag generated by WOTextField.

When the client submits the page with the WOTextField on it, the lastName of the manager of the department the user is in will be set by calling setLastName (or _setLastName, or setting the value of the field lastName or _lastName) on the manager object retrieved using KVC.

The associations in the WOD file are generally created for you by using the inspector panel in WebObjects Builder, the GUI HTML/XML component editor that comes with WO.

As you can imagine, using this pattern for displaying and setting everything in a [web] application will greatly reduce the amount of "garbage code" you have to write to wire you pages to your business objects.

Enter OGNL: most web development environments unfortunately do not have this wondeful notion of separating sub-componenent associations from the HTML file, which causes the whole mess of code-in-HTML that plagues ASP and JSP, PHP, etc. And KVC is specific to Apple's Foundation framework used in Cocoa and WebObjects.

OGNL extends the KVC concept by allowing expressions and access to array elements by index, and much more.

OGNL works just as well for associating objects between the view and controller layers of GUI code, of course. Check it out...

I might also note that Luke Blanshard is sitting on a very slick XML-RPC client implementation written in Objective-C. :-(

Written on July 22, 2001