Archive for April, 2006

Uncategorized

Java 5 Update for OSX

I took the new update for my java on my mac yesterday. At first i didnt notice any problems. But after a restart of CF I found it was using the new java and was not particularly happy. Some things worked fine but others were broken. As java 5 is an unsupported platform for ColdFusion MX 7 ( i think), I just wanted an easy way to downgrade my jre. After a quick search I found this article on Mac OS X Hints. This worked great for me.

Here is a way to make this happen. Open up TextEdit and paste in the code below.

#!/bin/sh

cd /System/Library/Frameworks/JavaVM.framework/Versions

CURJDK="`readlink CurrentJDK`"
echo Current JDK version: $CURJDK

if [ "$1" == "" ]; then
echo Installed versions:
ls
exit
fi

VERFOUND=`ls | grep $1 | head -n 1`

if [ "$VERFOUND" != "$1" ]; then
BASE="`basename $0`"
echo Error: Could not change JDK-- version $1 not installed!
echo Run $BASE without arguments to see a list of installed versions.
exit 127
fi

echo You must now enter your Mac OS X password to change the JDK.
sudo ln -fhsv $1 CurrentJDK

Save the file to your home directory as setJDK. Now open up Terminal(Application/Utilities/Terminal) and at the command line type:


chmod +x setJDK

Now press enter to run the command. This makes the file we created a script that can be executed. Now on the command line enter:


./setJDK

And then press enter to run the command. You will see output to the screen the list of java version you have installed. After picking the one you want ( I wanted 1.4.2 ) run this:


./setJDK 1.4.2

And press enter 1 last time to set your JDK version. Thats it. You can easily switch to another version or back to 5 if you like.

Good Luck

Uncategorized

If I could offer you only one tip….

Ladies and Gentlemen of the Flex 2/Coldfusion Remoting Development Community, If I could offer you only one tip for your future, Staring ColdFusion from the command line would be it.

When you start coldfusion from the command line not only does it give you a good idea of what actually happens when CF starts up, but there is a great deal of information that also gets displayed in that little window. When using Flex 2.0 remoting that information can save you from loosing your hair and gaining ulcers.

All of the information that is passed from CF to Flex and from Flex to CF gets output in that screen in a wonderfully easy to digest manner. Including when you pass an object from flex to coldfusion, you can see what exactly is being passed and how cf sees it. Why would this be important? Well what if CF doesnt realize that it needs to turn the data from your User.as file into a User.cfc object? The only error you are going to get in cf is that the argument passed to your function is not of the right type. But you wont know why :)

So for you windows folks you will mostly likely be running something like this from your command line:

JRun4injrun -start cfusion

or for mac users something like:

/Applications/JRun4/bin/jrun -start cfusion

Both of those assume you are running the multiserver version of CF, and you can exchange the word “cfusion” for whichever cf instance you would like to start up.

I have talked to many developers now that are troubleshooting remoting problems and this is one of the first things I have them do. Quite often it is the only step I have to help them with because once they see the output they often can figure out their woes :)

Good Luck in your Remoting Adventures!

Uncategorized

BACFUG Presentation - Simple Flex 2 ColdFusion Remoting Example

Well I had the opportunity to present to the BACFUG tonight on Flex Remoting with ColdFusion. I had a couple bits of technical difficulties, and as always I rambled a bit, but on the whole I think people got what they came for.

That being an example of how to pass data back and forth from Flex 2.0 and ColdFusion. So we started with a simple database table for my “users”. The table just had fields for id, fname, lname, and email. We then used the RDS Plugin for eclipse to do some code generation. We created an active record style User.cfc and a matching User.as file. From there we created a userService.cfc which acted as the endpoint for flex rpc calls. We wrote 3 methods to that service: getUsers, saveUser, and deleteUser. And we implemented a simple GUI for interacting with those services.




I promised to make the source code available and so I am. You can download simpleRemoting-0.1.zip here

Uncategorized

Using Flex 2 List Controls with data from ColdFusion Components

When I started building apps with Flex 2, i found i had a problem with my list controls. To be honest I just assumed it was a bug. Whenever i returned an array of objects from a ColdFusion Component to my Flex 2 app, I found the visual activity of my list didnt work quite right. What I mean is that the mouse over and selected visual highlights didnt happen.

I started to do a little bit of research and found that your new AS objects (which the AMF gateway translates from your CFC’s) need to implement the IUID interface so that the listBased control can tell the items apart. implementing the IUID interface fixed my visual problems completely.

But once I had done that I found I was unable to pass my AS objects back to CF and have them be correctly recognized. In looking at the debug info from CF I saw that once I had implemented that interface my object had a new property. the “mx_internal_uid” property. In order for CF to translate your CFC to their AS counterparts you must use cfproperty to define the instance vars of your object, as well as define all your instance vars in your AS object. And the 2 sets of properties must be in the same order. So I added the mx_internal_uid to both my Objects, but this didnt have any effect on my problem.

In working a bit further I found that if I removed the interface but left the new vars everything worked fine. So it appears by implementing the interface the CF AMF gateway is not able to get the type for the object correctly anymore.

After asking around about this for a bit, i found a work around. Although implementing the IUID interface is the correct method for making the lists work, there is another solution. After talking about my problem with Darron Schall, he asked what happened if I removed my interface in the AS object, but implemented the class as “dynamic”. I made this change and found that everything worked great. I removed my extra properties I had added for the interface, and found that everything still works fine.

Defining the AS object as dynamic allows properties to be added to the object at run time. This allows the list dataprovider to add the uid property without messing up whatever signature cf uses to identify what object is being passes to the gateway.

If you have a solution for implementing IUID without breaking the amf gateway I would love to hear it. But for others running into this problem, here is a solution :)

Personal

Not Too Nerdy?

Ok, so I saw this all over the blog world and i wasnt sure what to think. I saw mark d in the 50’s and I thought I saw vince b was in the 90’s. So I just decided I needed to find out for my self.

I am nerdier than 71% of all people. Are you nerdier? Click here to find out!

Go Try It, its kinda fun :)

Uncategorized

April Portland Adobe User Group Meeting

I think i have forgotten to post the last couple meetings here, so I wanted to get this up. Next week, Thursday April 20th, we will have Barney Boisvert presenting on “JS Remoting and Composite UIs” Or for the buzz-word enabled AJAX.

Meeting at 6pm. Details on the http://www.pdxcfug.com website!