Helping Hands

i have made it a point over the years to keep in touch with developers I meet and offer help wherever I can. I'm not great at posting to the mailing lists because I usually get so caught up in what I'm doing that I forget to read them :)

Lots of people ping me during the day (and sometimes night) for help with cf / flex/ javascript / css etc etc, and there are a bunch of people on my list who I have asked for help with the same when I'm having a brain fart or when I'm doing something i've never done before. Some of the people on my list have spent an awful lot of time helping me on occasions, and I always try to return the favour.

The point I'm making is this - network with other developers, stay in touch and reach out when you need help. But more importantly, be ready to help someone out if they ask you a question too - this doesn't mean drop everything you're doing and do their work for them, but if you've got 5 minutes then share it. A lot of people, including experienced developers, don't realize how powerful a tool your network of tech savvy friends can be. I'll be going into more detail about this in my talk at Scotch and (hopefully) WebDU, but I just wanted to throw a quick word out to any who might be listening.

Today I was doing battle with some really appalling actionscript 1 code. I love actionscript 3.... a lovely fellow named Campbell Anderson, who has answered more than a few of my irritating as1 questions lately, has quite patiently helped me through some very weird issues and saved me a lot of time and frustration. I'll be making sure he knows he's appreciated :)

This is one of the great strengths of the cf community, and i'm finding it more and more in flex and flash too. Be generous with your time, and you'll find that when that moment comes when you really are stuck in a hole for whatever reason, you have allies on hand to help you out.

After all, many minds make light work.

Speaking at Scotch on the Rocks

Yup I'll be speaking at Scotch on the Rocks in Edinburgh, Scotland in june. I'm very very excited, and hopefully won't be completely boring - I'm speaking alongside a raft of the top people in our industry so a little intimidating :D Maybe I'll just get drunk before my presentation...

If you're going to Scotch I'll look forward to seeing you there!

Certifiable!

After 8 years or so I finally got around to taking the Coldfusion developers exam this morning. I am now an Adobe Certified Advanced Coldfusion Developer and an Adobe Certified Advanced Coldfusion Trainer! So probably in 6 months time I'll be listed as such on the adobe websites...

Flex exam in jan then my trainer certs will all be complete.

Chemists

Anyone out there have any experience with chemistry and/or chemical biology? I have some questions I'd like to ask you if so, so drop me an email, I could use your help :)

Believe it or not it *is* actually on topic too...

Melbourne CFCamp Report

CFCamp in Melbourne was brilliant. It wasn't the greatest turnout but we had a good number of high caliber people there and the talks were excellent.

I particularly liked Peter Bell's talk about DSL's and Software Product Lines - I'll definitely be following up with Peter to learn more about this, as this is exactly where I've been heading.

After the camp a bunch of us went for drinks and I ended up having some very long (and slightly inebriated) discussions with Adam Lehman of Adobe and Peter Bell. Mark Mandel piked early ;) but I got to know Adam and Peter pretty well and had a fantastic evening. Thanks to all who turned up and especially those who spoke and organized the day - it's well worth it, and hopefully we will see more of this sort of thing in the near future.

Speaking at Melbourne CFCamp

It looks as though we'll be getting a CFCamp in Melbourne after all, through the efforts of Mark Mandel. The downside is he's conned me into speaking :D I'm giving a half hour talk on "Enterprise development for the rest of us" - basically what it really means to be an enterprise developer and how to ramp up your career and habits to get to that level. And seeing as I'll have a captive audience I might see if I can squeeze in a magic trick or two, so if my talk totally sucks there will at least be some entertainment.

Hope to see lots of people at cfcamp melbourne!

I hate dates and locales

Yes Yes Bad Blogger, I know. smack. Anyways....

I'm having a problem where i'm using a date selector in flex and selecting a date (client running on australian machines), but when its saved to the server it seems to be going in as a US date based on the current server time. How do I fix this? I've tried mucking about with the locale setting in the compiler arguments, I've tried just using CF_SQL_DATE instead of _TIMESTAMP but to no avail. If there are any readers left on this blog I'd appreciate any ideas.

I hate working with dates and regions, it's definitely on my top 5 least enjoyable things in programming.

Frustration

I just spent ages searching for this for someone, and thought I might as well post it here. This is how I often feel reading the threads on cfaussie...

CF Startup and shutdown on OSX

There's a simple and easy way to control CF instances on OSX (or flex / jrun for that matter). Get a little program called Lingon.

  1. Once installed, run it and click the "New" button (top left).
  2. Choose "Users Daemons"
  3. On the resulting screen, set the "Label" field as something like "CFMX Service"
  4. Use the plus icon to the right of the "Program Arguments" box to add the following arguments. These arguments should be in order, and each should be added as a seperate entry in the list (by clicking the little plus button again):
    1. /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Home/bin/java
    2. -server
    3. -Djava.awt.headless=true
    4. -jar
    5. /Applications/JRun4/lib/jrun.jar
    6. -start
    7. cfusion
  5. Cick "Just save" or "Save and Load" and you're done.

As you might imagine, you can change the last argument from "cfusion" to "flex" or whatever you named the instance of your FDS setup to create a service for starting your flex instance.

Bender Alpha Release

Finally! Ok you can now download an alpha release of Bender:

Bender Alpha 01 (Bender_alpha01.zip)

Please bear in mind this is a first release, and while it works for me your mileage may vary wildly. I would really appreciate hearing from anyone who had time to try this out, and has bugs, suggestions, corrections or criticisms.

Download the zip file, and expand it into your webroot, or somewhere that a cf mapping points to as "com". You shouldn't need to setup anything specific for flex, it will just use the default flash remoting adapters.

The following steps should get you up and running with Bender:

  1. Make sure Transfer release 0.6.3 or higher is installed and working
  2. Make sure /com points to the com directory from the bender zip file
  3. Browse to http://yourserver/com/ls/bender/tools/BenderClassGenerator.cfm
  4. Change the paths to match your settings and submit the form - this will create an actionscript class file for each definition in your Transfer.xml
  5. I haven't made the auto compiled swc bit yet, so for the moment, make sure you drop these class files into your flex application, along with com/ls/bender/as/Bender.as and import them in your code
  6. In your flex code you can now run operations like: bender.read(oUser, "User", userPK);

Operations:

bender.read(Class class, String TransferClassName, String primaryKey);

The first parameter for a read is an already instantiated object - one of the classes bender generated for you. You pass this in, and when the read is complete the object will contain the relevant data. The second parameter is the name of the object definition - the "class" attribute in your Transfer.xml The third is the unique identifier you'd normally use to retrieve that object via transfer.

make whatever changes you like to the data in the As objects then use:

bender.save(Class class);

just pass in the actionscript instance and this will automatically save back to the db.

MAPPINGS You can map functions to a custom CFC if you choose. For example, if you wanted a UserManager.cfc to do something with the user objects before they went to Transfer for saving, you could create a Bender.xml like so:

<?xml version="1.0" encoding="UTF-8"?>
<bender>
   <mappings>
       <mapping class="User" action="save" mapobject="UserManager" mapmethod="save" />
   </mappings>
</bender>

This will mean that when you use bender.save(myObj) in flex, the data will go to Bender on the coldfusion side and get translated into an appropriate TransferObject which will then be passed on to UserManager.save(TO). If you don't create a mapping for a particular method and class, it defaults to sending straight to Transfer.

CAVEATS: I had some issues in actionscript using methods named get and delete, so in Bender you call bender.read() and bender.del() instead. This may be something I did wrong and if so I'll fix it - but for the moment that's how it works.

Delete works the same way as save.

EVENTS When you have instantiated one of the bender-generated actionscript classes, you can set oMyObj.OLNDATA() and oMyObj.ONFAULT() to provide functions to which Bender will map upon data population or fault. For example, if you want a message shown to the user when you save something, you could do this:

public function showResults(obj : *) : void {
result_text.text = "Save Successful";
}
public function showFailure(obj : *) : void {
result_text.text = "Save Failed";
}

oObj.ONDATA(showResults);
oObj.ONFAULT(showFailure);
bender.save(oObj);

Please download the code and take a look - and I'd love to hear from anyone on ways to improve it. Let me know what works and what doesn't and contact me on this blog or on skype / icq / email etc etc.

P.S. I haven't added the SWC generation yet, but am working on it now and hopefully that will make integration of auto-generated as classes and the bender code into your flex app much easier. If anyone has any preferences or suggestions for this bit, please let me know.

Mind-Bender

A quick update - the Bender alpha release *is* imminent, but I got held up on some recursive code that was being obstreperous and I'm having to rethink the way I was handling cfc mappings.

I wanted to set it up so you could instantiate Bender and pass it in all the cfc's you want to map to, or be able to setup a ColdSpring definition with the relevant auto-wiring, but I realised that the flex component is talking directly to the bender component so this wouldn't work.

What I'm doing now is creating BenderService.cfc - a facade that manages the instantiation of Bender. You change the instance code at the top of this cfc to however you want to instantiate bender (EG a CS getBean() call) and the flex component talks to BenderService.cfc, which just passes traffic back and forth to Bender.cfc.

At the moment I'm wrestling with the best way to make it all happen, trying to pass in instantiated components and have them stored - it's getting there but a few finicky details with unnamed arguments etc are causing me grief. More as soon as it comes.

PS. btw any comments on this would be greatly appreciated - any suggestions on how best to set it up, especially from anyone who knows coldspring would be fantastic.

More Entries