Default Sorting for a Flex DataGrid

June 15th, 2007

While working on the DeveloperCircuit Flex widget, I had the need to set a default sorting for a Flex DataGrid control. The standard control does not provide a mechanism to do this.

The Flex documentation suggests that you sort the underlying dataset, however I felt that this was very unsatisfactory. When you manually sort a DataGrid, the column which is being used to sort the data and the order of the sort, ascending or descending, is shown by the way of little black arrow in the column header. I felt that the default sorting should also be communicated to the user by this mechanism.

After some experimentation, this is the solution I came up with. There is a DataGrid event which is called when the user sorts a column. By announcing this event manually, once the underling data set has been returned by a call to a back end server, one can simulate the user action and set the default sorting of the DataGrid, complete with arrow. Example below:

<mx:RemoteObject
	id="someService"
	destination="ColdFusion"
	source="{this.someServiceLocation}"
	showBusyCursor="false"
	result="this.someDataGrid.dispatchEvent
	(
		new DataGridEvent
		(
			DataGridEvent.HEADER_RELEASE,
			false,
			true,
			0,	// The zero-based index of the column to sort in the DataGrid object's columns array.
			null,
			0,
			null,
			null,
			0
		)
	);"
/>

Consuming a .NET Web Service with Complex Types

June 9th, 2007

Although simple types such as string and int will be automatically handled by ColdFusion’s SOAP mechanisms, the complex types “made up” by .NET are not. This results in “type mismatch” errors.

The following describes the steps needed to use a .NET service with complex types. The ArrayOfString type and a MyDotNetComp Sales API are used as an example.

  1. Try to use the service and get a “type mismatch” error. The Java AXIS system will create .class files for each interface in the service.
  2. Browse the “C:\CFusionMX7\stubs\” folder for these files. They will be under a folder structure unique to the service being called. For example the folder for Travelex is “C:\CFusionMX7\stubs\sometemp\com.mydotnetcomp.www\”.
  3. Copy the whole of this folder to “C:\CFusionMX7\wwwroot\WEB-INF\classes\”. For example, “C:\CFusionMX7\wwwroot\WEB-INF\classes\com.mydotnetcomp.www\”
  4. Add the path “C:\CFusionMX7\wwwroot\WEB-INF\classes\” to the ‘ColdFusion Class Path’ in the ColdFusion Administrator in the ‘Server Settings > Java and JVM’ section and restart the ColdFusion server. This step is required for AXIS to access the .class files.
  5. One of the .class files in this example folder will be ArrayOfString.class which maps the ArrayOfString complex type defined for the web service.
  6. This .class file can be used as an object type and used in the call to the web service, as shown in the example below;
<cfset ary = listToArray("abc", "def", "ghi") />

<cfset aofs = createObject("java", "com.mydotnetcomp.www.ArrayOfString").init() />

<cfset aofs.setString(ary) />

Hello Blogosphere

May 29th, 2007

Well I have finally given up and joined the rest of the on-line blogging community. :-)

It’s a bit rough around the edges at the moment, as I still have a lot of CSS styling to do on my custom WordPress theme.

This blog will be dedicated to Internet Software Development, including; XHTML, CSS, ColdFusion, Flex, SQL and the like.


Copyright © 2005, David Beale

  • Valid XHTML 1.0!
  • Valid CSS
  • Level Triple-A conformance icon, W3C-WAI Web Content Accessibility Guidelines 1.0