Rotating Text in Flex

January 11th, 2008

The Flex docs tell you that in order to use Fade effects with Text controls, you have to embed a True Type Font to use in the Flex application. The default Fonts available within Flex (Aerial, Verdana etc) will not fade.

This also applies to rotating Flex controls, which is not mentioned in the docs - as far as I can see.


Scotch of the Rocks 2007 Article

August 27th, 2007

I attended this years Scotch of the Rocks with a press pass from Fusion Authority, and they have just published the articles that I and fellow “member of the press” Kola Oyedeji wrote as reviews of the conference.

Read them at A Tale of CFML, Flex and a Pineapple and A Review of Scotch on the Rocks 2007 respectively.


Automatic Disabled Icon with Flex Button Control

July 29th, 2007

The Flex Button control provides the means to add an icon to the button, in one of several states disabled/hover etc. However it does not automatically provide a disabled version of the icon you add for its normal enabled state. i.e. A “grayed out” version, which most other visual RAD tools would provided.

After hacking around in the Flex SDK, I found the following code which accomplishes this;

// Fade Disabled Icon

DisplayObject(this.getChildByName("disabledIcon")).alpha = 0.4;

This could be used as follows to produce an EditButton class;

<?xml version="1.0" encoding="utf-8"?>

<mx:Button xmlns:mx="http://www.adobe.com/2006/mxml"
	icon="@Embed('EditButton.png')"
	label="Edit" creationComplete="init();"
>
        <mx:Metadata>
		[IconFile("EditButton.png")]
	</mx:Metadata>

	<mx:Script>

 	<![CDATA[

		private function init():void
		{
    			// Fade Disabled Icon
			DisplayObject(this.getChildByName("disabledIcon")).alpha = 0.4;
		}

	]]>

 	</mx:Script>

</mx:Button>

As I believe this to be a very valuable behavior, I have created a new IconButton Flex Component class to download, which provides a Button control which does automatically provided a disabled version of its main icon.


Railo Customer Service

June 25th, 2007

I have just installed my first Railo CFML Engine in a production environment.

There was a problem with changing the licence from Community to Profressional. So I emailed Railo and within minutes they came back with a custom solution to my problem.

Now thats what I call Customer Service!!


How to do an OUTER JOIN in Query of Queries

June 20th, 2007

ColdFusion Query of Queries does not natively support OUTER JOINs. The following code demonstrates a work around to perform a LEFT OUTER JOIN between two CF queries, QueryA and QueryB.

i.e. To do this;

SELECT *
FROM QueryA
LEFT OUTER JOIN QueryB ON QueryA.ID = QueryB.ID

One can use;

<cfquery name="joinQuery" dbtype="query" >
SELECT *
FROM QueryB
WHERE QueryB.ID = -1
</cfquery>

<cfset QueryAddRow(joinQuery) />

<cfquery name="result" dbtype="query" >
SELECT *
FROM QueryA, QueryB
WHERE QueryA.ID = QueryB.ID

UNION

SELECT QueryA.*, joinQuery.*
FROM QueryA, joinQuery
WHERE QueryA.ID NOT IN (#ValueList(QueryB.ID)#)
</cfquery>

A common use of an OUTER JOIN is to find the non-matching records between two record sets, a so called NULL Based OUTER JOIN.

e.g.

SELECT *
FROM QueryA
LEFT OUTER JOIN QueryB ON QueryA.ID = QueryB.ID
WHERE QueryB.ID IS NULL

This situation can be more efficiently implemented in Query of Queries by using the following technique;

SELECT *
FROM QueryA
WHERE QueryA.ID NOT IN (#ValueList(QueryB.ID)#)

ColdFusion and SQL 2005 Mirroring

June 17th, 2007

After much experimentation, I have finally managed to get Microsoft SQL 2005 Mirroring with automatic failover working with ColdFusion MX 6/7.

The following steps describe how to setup ColdFusion.

  1. Install the latest version of the DataDirect drivers by following these instructions on the Adobe web site - Updated DataDirect JDBC drivers (version 3.5)
  2. Create a new ColdFusion datasource of type “Other”.
  3. Enter the following settings, replacing XXXs with your details;
CF Data Source Name XXX
JDBC URL jdbc:macromedia:sqlserver://192.168.1.XXX:1433;
databaseName=XXX;SelectMethod=direct;
sendStringParametersAsUnicode=false;
MaxPooledStatements=1000;
AlternateServers=(192.168.1.XXX:1433)
Driver Class macromedia.jdbc.MacromediaDriver
Driver Name SQL 2005
User Name XXX
Password XXX

You should now be able to manually failover the mirrored database and, after an initial ColdFusion connection reset error, your application to run as normal.

Simple when you now how! :-)


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