Scroll Through Tabs in Flex with Mouse Wheel

I blogged the other day about an Office 2007 feature for the tabs that are apart of the ribbon in that you can use your scroll wheel to change the selected tab. I thought this was actually pretty cool.

I decided to implement it in Flex because I figure it would be extremely easy... and it was! Took about 15 minutes total. However, it seems it is having issue when playing without a breakpoint in the code. Just playing through normally, when I scroll up or down, it actually seems to skip a tab when going through them. Yet, if I put a breakpoint at the beginning of the event handler and play through it that way, it goes to the next tab as it should.

Here is a demo of what I have done. Source is included...

http://www.kylehayes.info/tabby/TabThumbWheel.html

Easily Add VirtualHosts to Leopard 10.5

The Leopard upgrade to OS X changed a few things with the local web server configuration. Namely, it comes standard with Apache2 now which means that VirtualHosts are done differently as well now. After attempting to add my own custom VirtualHosts to what I thought was the right conf file, I gave up and found a better solution.

Patrick Gibson provides a great little shell script that I simply run with the name of the VirtualHost that I want to create and it automatically makes all the appropriate changes to the VirtualHosts conf file as well as the "hosts" file. More information here:

http://patrickgibson.com/utilities/virtualhost/

Scroll-Wheel Functionality in Office 2007 Tabs

It was said that the introduction of the unified ribbon toolbar in Office 2007 would increase the productivity and efficiency of its users. With my experience thus far, this has really yet to be the case.

However, today, I accidentally stumbled across and interesting feature that I think could be wisely used in other tab controlled interfaces (e.g. modern web browsers). While your mouse is in the boundary of any of the application ribbons in Office 2007, if you scroll your mouse wheel, the tab index advances (scroll up) or regresses (scroll down). It seems to be very quick and responsive on my system.

I find this to be very useful for getting to content even quicker and would be quite cool to see this in Firefox or even other applications like Photoshop and Illustrator where tabbed content lives on.

New Google Group for iPhone Developers

In an effort to bring iPhone developers together to share ideas and collaborate with each other, I have created a new Google Group, iPhone Developers.

I have been learning this technology lately. As a newbie to both OS X development, iPhone development, Objective-C, and the Cocoa framework, I wanted a central place to gather help from those in this brand new community. Seeing as Google Groups is pretty much the best place to host a message board as it only requires a Google account, I have started this group here.

Please invite those you think may be interested in joining. Would love to see Mac and iPhone developers alike join this group.

iPhone Developers Google Group: http://groups.google.com/group/iphone-developers

Race Your Typing Skills Live Against Others

Normally I am against link spamming but this game is just simply too much fun. It is also a novel and unique concept I have to share it: http://play.typeracer.com/

You are competing against a set of people in real time to see who can type the fastest! Very fun!

Interface Builder 3 and Creating Classes

Apple made many changes with the release of XCode 3 and Interface Builder 3 with the OS X Leopard operating system for the Mac. The workflow for these toolsets is very good as to be expected. With the release of these latest versions they aimed to provide an even more strict bound toolset to the ideals of the MVC paradigm.

In previous versions of Interface Builder, whilst creating your views for your application, you could quickly create a subclass of an existing object, say NSObject, by clicking the "Classes" tab and Control-clicking a class to subclass it into your own custom class. Apple realized this was probably not the best form as it allowed you to basically be creating part of the model within the wrong part of the IDE. The model should be created within XCode itself where all the other classes are developed. In Interface Builder 3, you can no longer subclass. You need to go back to XCode and create your class there, then when you go into Interface Builder, drag a generic Object/ObjectController and drop it in your nib. From there, inside the Inspector under Name, start typing the name of the custom class you created in XCode and push return after it has auto-completed. This will in turn apply the parent class to your custom class.

Make One Change Today...

Earth Day 2008 A couple of months ago when I started my job at Disney and my commute changed to a little over an hour at 100 miles a day, I realized that I needed to sell my Jeep to decrease the cost in how much I was spending on fuel every month and purchase a Toyota Prius. At least, that was the initial reason. However, since that purchase, I've become ever more aware of the carbon footprint my family has on Earth.

I have always been somewhat interested in making that step towards a greener life but have never really made an effort. Purchasing my Prius has encouraged me to continue to evaluate my life and see where I can make small changes here and there.

After looking through National Geographic'sThe Green Guide, I learned that we can make a difference even with small and simple changes. You certainly don't need to sell your car to be more green. Little changes here and there will better the life around you.

About a year ago, my wife and I replaced has many light bulbs around the home as we could with CFLs to not only save money by not having to replace our bulbs as often, but to also save money in electricity usage throughout the year.

According to a recent report, citizens of Southern California drink the most bottled water in the nation. Many of us have gotten used to this luxury and think that tap water is absolutely horrid and disgusting. Yet won't people don't realize is how bad that plastic bottle is for our environment. My wife and I are guilty of drinking lots of bottled water as we don't have a tap in our refrigerator. We would buy three cases of Kirkland Signature bottled water from Costco about once a month (I think each case may have had 35 bottles or so). With that I decided that was one of the changes I wanted to make to reduce the amount of plastic waste I was generating. I have completely stopped drinking bottled water altogether now and only drink tap water. When I am at work, I fill up my durable plastic drinking bottle with the Arrowhead water they provide us that is delivered in the large bottles that Arrowhead reuses. This change is small and tap water doesn't taste as bad once you have acclimated to it. In fact, I actually prefer it now. I was not able to convince my wife to completely switch over to tap, but she has switched over to Arrowhead bottled water as they now use 30% less plastic.

As someone who tends to print out content from the computer more than I really need to, another change that I am testing out is using recycled printer paper in my laser printer. The first ream I am testing is Staples brand 100% recycled paper. It is thinner than I would like my paper to be. After this ream is up, I may switch to 30% or find a different brand to try out.

Overall, I have attempted to take a second look of what I use in everyday life to see how I can improve my green factor. I hope that you will see how easy it is to make simple changes in your everyday life and encourage others to do the same.

I invite you to join me in making a difference. Sign up with MakeMeSustainable.com to learn more about how you can.

For more resources on the small steps you can take, visit the following for more information:

[PIC] Bug Carries More Than Its Weight...

Driving home from Fry's Electronics this past weekend, my wife and I could not help but laugh and snap a shot of the many uses a VW bug provides to it's owner: VW Bug Overloaded

Transfer and Flex: Part 1

I started a project a couple of months ago that has and is going to continually have a very complex and growing architecture. The technology stack in place is Flex 3, Cairngorm 2.2, ColdFusion 8, ColdSpring, Transfer, and SQL Server 2005. This is my first Flex application that will be using Transfer to handle the database abstraction layer. Normally, I would use Brian Rinadi's Illudium PU-36 CFCGenerator to handle the initial generation of all my CFCs and from there would either modify the XSLT files or simply append to the generated CFCs as I saw fit.

The problem with this type of approach lies namely in the early stages of application design and development (especially since I traditionally don't go through a line of specs working on a solo project) when the database is going through many changes. Each time you make a change to the database, you either have to regenerate your files which will overwrite any changes you made, or you have to manually hand-code the database changes. On top of this, it doesn't take care of any of your table relationships as per a 3rd normal form database structure. You then have to design your own home-brew setup of such a system if you require it, or simply provide functions that return the structs/VOs to Flex as you need them by manually building up the hierarchical tree of the model.

For this project, I knew from the beginning that the database schema was going to be pretty complex and that it was also going to be going through changes as I developed and tried things out. I knew that I wanted to get Transfer to work with Flex. I had tried this once in the past and failed because I was designing Flex applications differently at that time. I now know better to design with a service layer in mind.

Although, it is not that easy either. There are actually quite a few steps involved when using Transfer to interact with your database and to return the right kind of objects back to Flex. Also, let me state, that I am talking about this in terms of using the AMF protocol with RemoteObjects between ColdFusion and Flex so that datatypes are appropriately and quickly translated.

This post will first introduce the Transfer ORM framework and why it is not a basic task to integrate it into your ColdFusion / Flex application. In the next part of this article, I will discuss the technical details of getting this all to work.

Transfer ORM framework

Visit project website

ORM, or Object-Relational Mapping, in simplistic terms is abstracting a representation of your data inside a database as objects in your application. An ORM framework does all of this abstraction semi-automatically by means of introspection to your database and generating the necessary files, or by a configuration file that describes the datatypes and the relationships of the tables to each other. Transfer falls into the latter category.

While some say that a fault of Transfer (esp when compared to a competing framework, Reactor) is that you have to write the table structure and it's relationships manually in an XML file. Whereas Reactor is a framework that reads the database metadata. At first, I thought this same thing and after working with Transfer later, have found it much better to be in control and to define the relationships myself. With this method I really feel like I have a much better understanding of what Transfer is creating when it generates it's objects. Plus when debugging your code it is easier to see what columns/fields are causing issues in your relationships.

The benefits of using Transfer over generating the CFCs yourself using tools like Brian Rinaldi's Illudium PU-36 CFCGenerator is that once you have defined your XML file, the actual creation of the CFCs is completely automatic. To give you an example, let's say you have a table in your database called Employee that has the following fields: employeeId, firstName, lastName, email. Once you have instantiated the TransferFactory, you simply call the object the you would any other VO, only you haven't previously written it:

<cfset firstName = variables.Transfer.get('employee', 1).getFirstName() />

Transfer.get() retrieves a specific Transfer object (which is defined in your Transfer XML) with a Primary Key ID of "1". Then it simply calls the generated "getFirstName()" method on that object and returns it to you. That's it! It is really simple.

This is hardly even skimming the surface of what Transfer does for you. Let's say that an employee can have multiple phone numbers on file that you store in a separate table called EmployeePhone. This is of course a One-to-Many relationship. Once you have simply defined this relationship in your Transfer XML you would then access the phone numbers this way:

<cfset emp = variables.Transfer.get('employee', 1) />
<cfset empPhoneArray = emp.getPhoneArray() />

From there you can simply loop through that array which in turn provides different EmployeePhone Transfer objects. You can configure in your XML whether that relationship will return an array or query. Notice that I mentioned it would return an array of Transfer Objects. This is where it gets tricky. The default return type of any relational object is typed as a Transfer Object. This is instantiated from the generic Transfer Object interface in the framework and is what all the relational object inherit from. However, you can change this by applying a decorator to any of your objects which will change the type of the object to the decorator path. The decorator will also allow you to add methods as well as change existing ones that the Transfer Object defines.

As you can see, Transfer can be very very powerful in your applications. It doesn't require very much setup time and configuration. As with most advanced concepts like this, it takes practice to really understand the underlying methodologies and to use them wisely in your application. Also, do not think that Transfer is simply a glorified code generator. Mark Mandel has spent a lot of time utilizing ColdFusion's unique strengths to truly make this a fast and effecient framework to keep your application at top speed.

That's it for now. Next time I will actually get more technical about the configuration file and start discussing how to prepare your CFC middle-tier for Flex consumption.

Related reading: