Viewing by month: December 2006

Dec 27 2006

Model-Glue 2.0 ("Unity") Beta 2 Update

I'm making progress towards a second beta of Model-Glue 2.0. Most of the tickets are closed, and I'm working on documentation.

Currently, I hope to release the second Beta in the first week of the new year.

This next bit is important.

If you've developed applications using Beta 1 that use ORM services, and you get the latest code from SVN, your application will crash.

This is because I've moved a few bits of Reactor-specific ORM configuration out of the core files and into the application's ColdSpring.xml file.

To get things running again, add the following to your ColdSpring.xml file. This is part of what I'm working on documenting (in a new help doc entitled "Using Model-Glue with the Reactor ORM Framework").

<bean id="ormAdapter" class="ModelGlue.unity.orm.ReactorAdapter">
   <constructor-arg name="framework"><ref bean="ModelGlue" /></constructor-arg>
</bean>

<bean id="ormService" class="reactor.reactorFactory">
   <constructor-arg name="configuration"><ref bean="reactorConfiguration" /></constructor-arg>
</bean>

15 comments - Posted by Joe Rinehart at 8:12 AM - Categories: Model-Glue

Dec 13 2006

Cairngorm for MG/ColdFusion Developers (Part 5, Commands and Events)

In part five of this series, we're going to get to some of the real core of Cairngorm: events and commands. I'm going to be drawing parallels to the Model-Glue and Mach-ii frameworks for ColdFusion, but I'll still explain things from scratch as well. At the core of the matter, events and commands implement Implicit Invocation: when a UI gesture is handled, such as clicking a button, that "click handler" has no idea what code the controller ultimately invokes.

Well, that skipped ahead about five paragraphs, but should have "clicked" for the MG/M2 crowd. Let's take it in pieces.

Read more...

4 comments - Posted by Joe Rinehart at 9:30 AM - Categories: Flex and ColdFusion

Dec 11 2006

HappyCamper- Another Flex-Based CFCUnit Frontend

A few days before CFCUnitRunner showed up, I started playing with Flex Data Services and the RemoteService parts of CFCUnit.

What I wanted was a way to "push" requests for test invocation to the browser based on changing files in certain directories. I've been using the end results for three or four days now, an I'm enjoying it, so I thought I'd release the code.

A screenshot is available at http://www.firemoss.com/images/happycamper.png - you can add a test class manually using the top-left box, the list of known tests shows up on the left, and the right side shows test results. What I like about this vs. CFCUnitRunner is that FDS can trigger multiple tests, and you can click a test to see its last results without rerunning the test.

It's not going to be a product or anything like that - basically, there's minimal documentation, I assume you know about event gateways and FDS, and it's kind of "this is all I need, so I'm not refining it or refactoring it" code, but I thought folks might find it interesting.

You can get the bits at http://happycamper.riaforge.org.

0 comments - Posted by Joe Rinehart at 5:36 PM - Categories: Flex and ColdFusion

Dec 11 2006

Cairngorm for MG/ColdFusion Developers (Part 4, Value Objects)

In part four of this series, we're going to learning about ValueObjects and the first of a few roles they'll play in our Cairngorm/ColdFusion application. In this context, they they serves as typed representations of our data. Most importantly, because they're not generic instances of Object, they're nicely bindable.

Introduction

In the last part of this series, we learned about the somewhat quirky singleton trick, commonly called getInstance(), that we can use to start making the members of our ModelLocators bindable.

Our goals in this part are:

1. Learn what a ValueObject is 2. Create a ValueObject to represent a Contact 3. Modify our ContactModelLocator to use Contact ValueObjects instead of generic Objects

So, what's a ValueObject?

In OO-ColdFusion parlance, a ValueObject is kind of like the Bean pattern we use to pass data around in ColdFusion. The only major difference is that instead of getters and setters, we can simply create properties. In Flex/AS3, you can define default getters and setters for a property that can then take over if you need to associate logic with a given accessor/mutator.

Example:

In ColdFusion, a ContactBean would probably have the following:

<cffunction name="getFirstname">
<cfreturn variables.firstname />
</cffunction>

<cffunction name="setFirstname">
<cfargument name="firstname" />
<cfset variables.firstname = arguments.firstname />
</cffunction>

In a Flex 2.0 ValueObject (VO from now on!), we just replace this with the following:

public var firstname:String;

That's a bit like doing "this.firstname" in ColdFusion, but with Flex, we can change it to this without altering the interface of the VO:

private var firstname:String;

public function get firstname():String {
return this.firstname;
}

public function set firstname(firstname:String):void {
this.firstname = firstname;
}

Uses of ValueObjects

First, ValueObjects provide a typed version of your data that you can then use throughout your application. One advantage of typing your data is code hinting: if we go to write a Contact form, and we're working with something like ContactModelLocator.currentContact, typing "ContactModelLocator.currentContact." will allow Flex Builder to present you a list of all of the availabile properties on the ContactVO.

Secondly, and more importantly, with a VO you can mark certain properties Bindable, or the entire Bean's public members Bindable.

A third aspect of VO's that's important is that they serve as a way to send typed information back and forth from ColdFusion, with ColdFusion mapping the ValueObjects to CFCs that you've written. We'll get to that in a later piece of this series.

A Contact VO

Ok, there's not much to explain here. The code is simple. The only thing to really note is that I've placed the [Bindable] metadata directive at the top of the class definition. For those following along at home with all of the parts of this series, create a directory named "vo" under the existing /com/firemoss/cg4cf/model directory in your Flex Builder 2 project.

In this file, paste the following code (and read it under you understand it - shouldn't take long!):

package com.firemoss.cg4cf.model.vo
{
   import com.adobe.cairngorm.vo.IValueObject;

   [Bindable]
   public class Contact implements IValueObject
   {
      public var contactId:Number;
      public var firstname:String;
      public var lastname:String;
      
      public function Contact() {
         this.contactId = 0;
         this.firstname = "";
         this.lastname = "";
      }
   }
}

That's that.

Using Contact VO's in our ContactModelLocator

Our next order of business is to modify our ContactModelLocator to use the Contact instead of the generic "Object" to represent our Contacts.

First, we need to import the new class, adding this import statement along side the other import statements:

import com.firemoss.cg4cf.model.vo.Contact;

Second, we'll change our little initialize() function to create contacts that are of type Contact instead of Object, changing lines like:

contact = new Object();

to

contact = new Contact();

Finishing Up

Ok, our datagrid and text box are now going to be using the typed, bindable Contact ValueObject. If we compile and run our application, type a bit in the text box, and click the button, we'll instantly get the update in the DataGrid.

Next Time

Now that we've figured out our binding woes, we'll move on to the next bit of our application: using Cairngorm features like Commands and Events to create a detail form that lets us add, edit, and delete a given contact. That'll pretty much wrap up the presentation tier of our application, at which point we're going to start talking about how we'll interact with the ColdFusion bits (which I'll just provide as a .zip) via things like Business Delegates.

1 comments - Posted by Joe Rinehart at 11:16 AM - Categories: Flex and ColdFusion

Dec 6 2006

Cairngorm for MG/ColdFusion Developers (Part 3, getInstance)

Sorry for the delay in the series - work happened! I haven't forgotten it - I've created the entire Contact Manager application and it ColdFusion backend (just using Memory/XML for storage), but I just haven't had time to blog the process.

Read more...

3 comments - Posted by Joe Rinehart at 3:32 PM - Categories: Flex and ColdFusion

Dec 5 2006

Flex 2: Building an animated "Sometimes" DividedBox

I've got a situation where I need to simulate the iTunes look of having a master list take up all of a panel's width/height, with the ability to optionally split the area into a divided box to show detail information.

With Flex 2, it's uber-easy to do this in a slick manner: you can just use a VDividedBox and states to add/remove the detail as the first child of the VDividedBox.

If you want to skip the explanation and see the finished product, it's available at:

http://www.firemoss.com/demos/flex/dividedbox/

Source code:

http://www.firemoss.com/demos/flex/dividedbox/srcview/index.html

I wanted to take this a bit further, though, and animate the transition. At first glance, you'd think you could do it by using two <mx:Transition> - one containing the <mx:Resize> that shows the detail, and another containing the <mx:Resize> that hides the detail.

Nope - it looks like the state change removes the detail area before playing the transition.

So, how can we get it to work? It's actually not bad at all: create a function called something like "hideDetail," move our "hide" resize our of a transition, and tell it to play hideDetail when it's done.

It wouldn't be hard to take this further, turning it into a reusable component extending the desired type of divided box.

9 comments - Posted by Joe Rinehart at 8:01 AM - Categories: Flex

Dec 4 2006

Flex 2 and ColdFusion: Are VO's always the way to go?

I'm working on an in-house Flex application right now, and I'm hitting a point where I'm concerned about the load associated with creating large collections of Value Objects.

Read more...

15 comments - Posted by Joe Rinehart at 7:32 AM - Categories: Flex and ColdFusion