Swiz 1.0RC Released! So here's an updated example, custom ViewMediator, and more

There's a lot of good news from the Swiz world today. First, we just released the Swiz 1.0 Release Candidate, which fixes a number of small bugs in the beta and adds numerous new features. This version should be pretty much feature-complete, so at this point we'll be focused on fixing any issues that come up. A final 1.0 should be out in the next few weeks.

I did my best to help out with this release by working hard on updated documentation. You can see the fruits of this labor on the new Swiz documentation wiki we've created through JIRA Studio. You can also sign up to enter feature requests or bugs, vote on issues, and all the other good stuff that JIRA provides. If you have any feedback on the documentation, feel free to leave a wiki comment and we'll do our best to address it.

I've also created a Swiz 1.0RC version of my example application. If you like, you can view or download the source code.

Since 1.0RC removes the option for "view injection" into a bean, folks have asked about ways to handle providing a view to a Swiz bean. I created a MediateView custom metadata extension that should handle most of these needs. I'll do my best to keep it up to date as I get feedback about it.

And finally, in the "better late than never" department, I've uploaded the Swiz presentation I gave at cf.Objective() 2010 to SlideSix. I'll also be speaking on Swiz at this year's CFUnited conference. If you're planning on going, I'm happy to talk about Swiz into the wee hours of the morning!

Comments Comments (6) | del.ico.us del.icio.us | Digg It! Digg It! | Linking Blogs Linking Blogs | 1157 Views

Swiz Example Application Updated to Support Swiz 1.0 Beta

Update on 8/16/10: With the release of Swiz RC1, I released an updated version of this example application.

With the release of the 1.0 Beta of the Swiz framework, I've updated my Swiz example application to the latest version. You can also view the source code if you like. I'd like to point out a few things that I had to change from the example based on version 0.6.4:

  • The instantiation of the framework has changed in order to support multiple instances of Swiz, primarily for Flex module support:
    <swiz:SwizConfig id="mySwizConfig"
                     eventPackages="com.briankotek.swizdemo.event"
                     viewPackages="com.briankotek.swizdemo.view"
                     defaultFaultHandler="{genericFault}" />
    
    <swiz:Swiz id="mySwiz" beanProviders="{[Beans]}" config="{mySwizConfig}" />
    		
  • The static methods on the Swiz class have been removed, due to the fact that there can now be multiple instances of Swiz. This means that instead of doing something like Swiz.dispatchEvent( event ), you now want to inject a dispatcher object into your non-view objects and dispatch events through it instead. The two main ways to do this are to inject the dispatcher in your BeanLoader/BeanProvider, or by having your class implement the IDispatcherAware interface, which will instruct Swiz to inject the dispatcher automatically.
  • The [Autowire] metadata tag has been deprecated in favor of the more industry-standard [Inject]. [Autowire] will still work for now, but be aware that this may be removed in a future release.
  • The use of the earlier CommandChain has changed to support more robust and extensible chains, as well as supporting internal Flex event-based chains on top of the existing support for chains that make server calls. For example:
    var chain : CommandChain = new CommandChain();<br>
    chain.addMember( new AsyncChainStepCommand( delegate.deleteUser, [user], userDeleteHandler ) );<br>
    chain.addMember( new AsyncChainStepCommand( delegate.deleteUserProfileImage, [user], userProfileImageDeleteHandler ) );<br>
    chain.addEventListener( "chainComplete", userDeleteCompleteHandler, false, 0, true );<br>
    chain.start();
    		
Anyway, that's all for now, but I'll be posting more about the Swiz updates soon. If you're interested in seeing more about 1.0, have a look at Sam Ahn's demo of Swiz using AS3Signals. A very cool use of the brand new custom metadata support now available in Swiz!

Comments Comments (24) | del.ico.us del.icio.us | Digg It! Digg It! | Linking Blogs Linking Blogs | 2973 Views

Swiz 1.0 Beta is Live!

This morning, the Swiz team released the 1.0 Beta of the Swiz Framework. You can view the extensive list of updates at the Swiz web site. Have a look and try out the new features. We'll be doing a full update of the documentation as we prepare for the final release. I also have an updated version of my sample application about ready, and I will upload it and highlight the differences between 0.6.4 and 1.0. Stay tuned!

Comments Comments (0) | del.ico.us del.icio.us | Digg It! Digg It! | Linking Blogs Linking Blogs | 1125 Views

My CFinNC Presentations at SlideSix

I've uploaded my CFinNC presentations to SlideSix for anyone who's interested:

Object-Oriented Design Principles

Introduction to Swiz

Overall, CFinNC was great. I actually had to work for a large chunk of the weekend so aside from presenting and mingling with folks later in the evening, I didn't get to attend many other sessions. That said, everything looked top-notch while I was there. The conference unfolded very smoothly and all of the attendees seemed very engaged. Hats off to Dan Wilson and the entire volunteer team for pulling this off! This conference definitely held its own against the other CF conferences I've attended. It was very difficult to tell that it was completely free. Hopefully we can do it again next year!

Comments Comments (1) | del.ico.us del.icio.us | Digg It! Digg It! | Linking Blogs Linking Blogs | 1524 Views

Flex DataGridColumn Complex Properties Bug and Workaround

One Flex limitation I've had to work around for a long time is the need for having a complex property name as the dataField for a DataGridColumn, like this:

<mx:DataGridColumn headerText="Client" dataField="client.name" />
		

I had written a nice, generic, custom labelFunction as well as a custom NestedPropertyDataGridColumn to handle this, and it all seemed to work well.

I just discovered that the Flex team had addressed this in the Flex 3.4 SDK update, though I don't think you'd ever know it since I couldn't find any actual note that this was added. The only reason I discovered this was actually looking at the source code, and then finding this ticket in the Flex issue tracker.

So yay, we can use complex properties in our DataGridColumns now! Except...it's broken.

Ugh. Really, guys on the Flex team? This was added and no one ever bothered to click on the column to sort it? Hmph.

Anyway, as one workaround, you can use a custom DataGridColumn combined with a custom Sort to get proper sorting in most cases:

package com.briankotek.util.datagrid
{

import mx.collections.ListCollectionView;
import mx.controls.DataGrid;
import mx.controls.dataGridClasses.DataGridColumn;
import mx.core.mx_internal;
use namespace mx_internal;

/**
 * A custom DataGridColumn that supports sorting a column that has a nested child property path for the dataField value.
 */
public class DataGridColumnNested extends DataGridColumn
{
	public function DataGridColumnNested( columnName : String = null )
	{
		super( columnName );
	}

	/**
	 * Override itemToLabel to force a ComparableSort custom sort class onto the parent DataGrid dataProvider.
	 * This works around a bug in sorting columns with complex property names in the dataField value.
	 * @param data
	 * @return
	 */
	override public function itemToLabel( data : Object ) : String
	{
		var parent : DataGrid;
		if( owner && owner is DataGrid )
		{
			parent = owner as DataGrid;

			if( hasComplexFieldName && parent && parent.sortableColumns && parent.dataProvider is ListCollectionView &&
				(
					!( ListCollectionView( parent.dataProvider ).sort ) ||
					!( ListCollectionView( parent.dataProvider ).sort is ComparableSort )
				)
			  )
			{
				ListCollectionView( parent.dataProvider ).sort = new ComparableSort();
			}
		}
		return super.itemToLabel( data );
	}

}
}
		

package com.briankotek.util.datagrid
{
import mx.collections.Sort;
import mx.collections.SortField;

/**
 * Custom Sort class that forces the correct compareFunction for a given field to be used.
 */
public class ComparableSort extends Sort
{
	public function ComparableSort()
	{
		super();
	}

	override public function findItem( items:Array, values:Object, mode:String, returnInsertionIndex:Boolean = false, compareFunction:Function = null ):int
	{
		if( !compareFunction && fields && fields.length && fields[0] is SortField && SortField( fields[0] ).compareFunction )
		{
			compareFunction = SortField( fields[0] ).compareFunction;
		}
		return super.findItem( items, values, mode, returnInsertionIndex, compareFunction );
	}
}
}
		

This forces the custom Sort class onto the grid's dataProvider, and then forces the correct compareFunction from the SortField to be used by the Sort's findItem() method. Hopefully we'll get a fix for this soon, but in the meantime, maybe this workaround will help out some other folks.

Comments Comments (2) | del.ico.us del.icio.us | Digg It! Digg It! | Linking Blogs Linking Blogs | 1916 Views

Previous Entries / More Entries