Viewing by month: May 2007

May 9 2007

Model-Glue:Flex Service Autoproxies

I've floated a few .zips of Model-Glue:Flex around, and so far, so good. However, one person who's not currently doing much Flex development had what I feel will be a key piece of feedback: the early zip did a lot to implement implicit invocation and the friendliness of Model-Glue, but it did nothing to remove the boilerplate that often goes along with writing a Cairngorm application that uses a service layer.

The Problem

A lot of Flex developers, myself included, use Business Delegates to separate the implementation of server-side services from the rest of our application.

Big term, easy concept: the delegate just wraps all the functions of the service.

Then, when we want to call the server, a Command calls the method on the delegate, stating that the Command should be used as the responder.

This means that any time I'd like to work with a new server-side operation, I've got a few things that are going to either slow me down or mess me up:

  1. I've got to add boilerplate to the delegate:

    public function doSomething():void {

    var token:AsyncToken = service.listDynamicStrings();

    token.addResponder(command);

    }

  2. I've got to implement responder functions:

    public function result(data:Object):void { }

    public function fault(data:Object):void { }

  3. If, for some reason (rare, but I've hit it), I need to make two server-side requests in one command, I've got to monkey about with responder delegates to get them to call different methods in the command.

While it's not *that* much code to write, when you stack it on top of creating the Command class (which is really not much but a procedural script), an Event class, and having to relate the two in the Controller, there's a lot of typing to be done.

So, my earlier reviewer basically said "Can you get rid of the yuck? Maybe you could write a dynamic proxy, handling methods not being found, that'd wrap a service and let you assign result/fault functions?"

Model-Glue:Flex's Solution

Ugly terms like AsynchronousMethodProxy aside, I've cooked up something that has a real feel of Model-Glue "easiness" to it - it's a little loosely typed, but darned easy to use.

The "autoproxy" lets you ask for any AbstractService (like a RemoteObject tag) in your ServiceLocator and make arbitrary method calls, using the name of the server-side function (e.g., <cffunction>). You just pass it whatever arguments the function requires, an optional result function, and then an optional fault functions. It's a lot like prototype's style of making Ajax calls.

Ok, code works better than words. This is all you have to do to ask for a list of contacts and use it as the source of an ArrayCollection in a model locator:

// In controller
private var service:AbstractService = getService("contactService");
private var model:ModelLocator = ModelLocator.getInstance();

// Listener function in controller
public function listContacts(e:ModelGlueEvent):void {

   service.list (
      function(data:Object):void {
         model.contacts.source = data.result as Array;
      }
   )

}

Let's spice it up and add a filter string as an argument and a reference to a common fault function:

// Listener function in controller

public function listContacts(event:ModelGlueEvent):void {

   service.list (
      event.getValue("searchString"),
      function(data:Object):void {
         model.contacts.source = data.result as Array;
      },
      this.serverError
   )

}

private function serverError(data:Object) {
   Alert.show("Oops!");
}

Any takers, thoughts, flames?

13 comments - Posted by Joe Rinehart at 12:40 AM - Categories: Flex | Model-Glue:Flex | Cairngorm

May 7 2007

Model-Glue.com Outage

Not that it's a giant loss, but Model-Glue.com/net/org will be on and off today as DNS changes take place. Sorry for any inconvenience.

This will not effect the Trac or Subversion sites.

1 comments - Posted by Joe Rinehart at 12:44 PM - Categories: Model-Glue

May 6 2007

Frameworks Explorer Eclipse Plug-In

Mark Drew has released an absolutely fantastic visual "explorer" of your framework XML files, available over at his web site.

With it, you can drill through ColdSpring, Model-Glue, Mach-II, Fusebox, Reactor, and (I think?) Transfer XML configs, letting snippets-based assistants aid in managing the tags.

Mark's also done an ingenious bit with a three-stage parser that allows you to extend/alter the explorer's behavior, making it adaptable to your own XML as well!

1 comments - Posted by Joe Rinehart at 9:11 AM - Categories: Model-Glue

May 5 2007

Cx: ColdFusion 2012

Last night, Adam Lehman asked a group of us (myself, Chris Scott, Brian Kotek, Rob Gonda, and David Perez) what we'd like to see from ColdFusion given nothing but our imagination and a blank slate. I'm not going to be able to properly represent ideas from all of us, but I wanted to outline a core idea that came up: the idea of an almost entirely new Adobe application server building on the spirit of ColdFusion and current Adobe technologies. In my head, I nicknamed it Cx.

Here's what I'd love to see:

A rewrite of ColdFusion using an XML schema to create view scripts (.CXM) and components/clases (.CXC), and allowing inline scripting (in the theme of cfscript) and component creation in AS3.

How would it work? Let's start at the top, a simple query and display:

<cx:Template xmlns:cx="http://www.adobe.com/cxml/2012">

<!-- Function to layout pancake name -->
<cx:Script>
<![CDATA[

private function pancakeName(name:String):String {
   return uCase(name);
}

]]>
</cx:Script>

<cx:Query name="pancakes" datasource="breakfast">
   SELECT * FROM pancakes
</cx:Query>

<table>
<cx:Output query="pancakes">
   <tr>
      <td>{pancakeName(pancakes.name)}</td>
   </tr>
</cx:Output>
</table>

</cx:Template>

Now, a custom tag / component to display a pancake icon beside the name, stored in {project}/customtags/PancakeName.cxml:

<cx:Template xmlns:cx="http://www.adobe.com/cxml/2012">

<cx:Property name="name" type="string" />
<cx:Property name="icon" type="string" />

<cx:Output>
   <img src="images/{this.icon}" />{this.name}
</cx:Output>

</cx:Template>

Using it in our display in our custom namespace:

<cx:Template xmlns:cx="http://www.adobe.com/cxml/2012" xmlns:customtags="customtags.*">
...
   <td>
      <customtags:PancakeName name="{pancakes.name}" icon="{icon.name}" />
   </td>   
...
</cx:Template>

Lastly, two takes on modeling a pancake:

<cx:Component xmlns:cx="http://www.adobe.com/cxml/2012">

<!-- You get the idea... -->
<cx:Function name="getName">
</cx:Function>

</cx:Component>

Or in AS3:

package model {
   public class Pancake {
      public var pancakeId;Number = 0;
      public var icon:String;
      public var name:String;
   }
}

How would it work?

Honestly, no idea. I'm just tossing out how I'd love to work.

Business implications

I like the idea. I think it'd require a new name and a rebranding of ColdFusion, but this could be done in a way that still relates it to the CF community while appearing a "new" product to others. It could consolidate resources inside Adobe: AS3 would become an underlying language for both server-side and client-side languages.

Wish I knew how to write languages.

8 comments - Posted by Joe Rinehart at 10:37 AM - Categories: ColdFusion MX

May 4 2007

Raymond Camden joins Model-Glue

I'm proud of the Model-Glue project and its code. Its community support, however, is somewhat of a sore spot with me.

It's hard to know what you're good at until you try something. I've tried being a community leader for an OSS project, and I've found out I'm not very good.

Without any more fluffiness: today at cf.objective, Raymond Camden agreed to work with me on creating and filling a "Community Manager" role. There's no one I'd rather have: Raymond's proven his ability to create and support OSS ColdFusion software, and he's fantastic at talking about Model-Glue with ColdFusion developers. We'll be working out the details (Ray, up for dinner tonight?), but I'm hoping we'll see:

* A move to a better list system, such as Google Groups

* A new Model-Glue web site with proper forums

* (This one's a dream, and we'll need help doing it): Community driven "Actionpacks" that server as starting points for common applications, like calendars, etc.

If there's anything we've missed, or anything you'd like to see the Model-Glue team do, please let us know in comments or e-mail!

3 comments - Posted by Joe Rinehart at 4:19 PM - Categories: Model-Glue

May 4 2007

Model-Glue:Flex?

I figured I'd better blog this while I had some downtime at the cf.objective conference. In my Model-Glue session today, I previewed an experimental AS3 Model-Glue implementation of Model-Glue, providing a lighter weight / looser / more implicit architectural framework in comparison to something like Cairngorm.

There's no docs, I've written one sample app, and I'm not sure this'll ever be an 'official' Model-Glue thing, but I'd like to ask if anyone would be interested in taking a look: leave a comment and I'll send out a zip when it's ready...I need to do an FDS example and a Quickstart.

26 comments - Posted by Joe Rinehart at 4:13 PM - Categories: Flex | Model-Glue | Cairngorm

May 1 2007

Flex fun: SubscribableArrayCollection

After work today, I was playing with Apollo by writing a To-Do list. I wanted to have to-dos and be able to view all to-dos, complete to-dos, and incomplete to-dos. Nothing fancy.

View Example | Download the Code

However, I wanted to have lists showing both complete and incomplete lists visible at once.

Still not too hard: maintain a master collection of to-dos, and shuffle between the lists when one is saved. However, that's kind of not-very-elegant in a data binding environment.

I decided to solve it with a kind of different approach: I created a subclass of ArrayCollection called SubscribableArrayCollection. It allows other ArrayCollections to "subscribe" to its changes. These other collections can have their own filter functions, etc., that can define the "subscribed" collections as subsets / different perspectives of the master collection.

By extending SubscribableArrayCollection into TodoCollection that subscribes "complete" and "incomplete" properties, showing lists became this easy:

<!-- All -->
<mx:List dataProvider="{todos}" />
<!-- Complete -->
<mx:List dataProvider="{todos.complete}" />
<!-- Incomplete -->
<mx:List dataProvider="{todos.incomplete}" />

Whenever a Todo changes that's in the master collection (todo), the master forces the other two lists to refresh by resetting their underlying source array. Presto! - zero code to update the complete/incomplete lists.

Long live data binding!

6 comments - Posted by Joe Rinehart at 9:22 PM - Categories: Flex