Month: May 2008

Colloborative working model using BlazeDS

Flex using BlaseDS provides a messaging framework that allows you to publish and subscribe to messages. In his recent post Christophe Coenraets has provided an example (includes source code as well), that shows how can you do something similar.

I am in middle of understanding the architecture, hoping to build an article that explains how to use the same constructs in your application as well.


Nice name 🙂

I came across this Firefox add-on a few days back. My first reaction was “this is kewl”, but as I started to use the same with my Firefox and looked at the various stats for applications all of this started to look “Hot”. For a simple application that I was working on, I figured out that there were numerous ways of improving the performance – goes to show how bad a web designer I am!!

Hope it helps you improve on yours. Go get it.

MXNA is now Adobe Feeds – Newer and faster than ever. Pumped by ColdFusion 8.0.1 – please welcome the all new MXNA.

Questions people ask?

I was training a bunch of my team members and then came up with the following list of questions during the course of the training. Hoping that this could be useful to someone else as well, I am now posting this out in open.

What is the difference between “Metadata” and Custom Events?

<mx:Metadata /> when used on a flex component provides additional information to the Flex compiler. We generally use Metadata tags for defining additional events, styles etc. Use the following code to insert a new event on your custom control.

  [Event("myEvent", "com.myevents.customevent")]

In this case when we expose this event via a meatdata tag, any consumer of my control can capture this event and whenever the component dispatches the event the consumer will be notified.

Can we have nested components?

Yes, we can. But we should avoid nesting may container as they can impact performance. Should red my entry a while back on Creating Layouts.

How can we chain events?

When we say chain events in this case, the real question was that can we sequence events if needed and make the Flex a more of single-threaded application. Short answer is “yes we can”. Long answer can be found in an upcoming blog.

More to come…

What is the scope of an Event?

What are various phases of events?

What is E4X?

How do we capture Mouse right click?

A partnership of its kind

Adobe announced Open Screen Project which kicks off May 1. Pretty influential group of leaders come together to create a consistent runtime environment that removes barrier of delivery of content and applications to everything.

Flex Java bridge – Communicating errors to Client

When you have a stack that has similar technologies (J2EE) it is very easy to report errors/exceptions across different layers. But, this very soon becomes a very interesting and nail biting issue across platforms.

A few days back one of my module leads came up to me and said that they have not been able to understand what are the exceptions that are being raised on J2EE server. Hence, the client Flex in our case can not report the root cause to the user. This is now becoming a mess as we need to handle usability and a better feedback to the user appropriately.

I started to think that there has to be some way to find that out and finally after a few hours of reading through the documentation I know how to solve the problem. But, before I take a deep dive into that solution i will quickly run through my architecture so that you understand in what constraints have I tried to solve the problem.

On the back-end I have Spring beans which are sitting in JBoss container. On the client I am using Flex 3 and Remote Objects to connect over AMF to Java. But, channel is not an issue here.

Java Code

One of the very common patterns that I have been using for Exceptions is to define custom exceptions that represent business errors. Example: If user is requesting an object but that that object is no longer a valid object, then always throw an exception named “ObjectNotFoundException”. The message should be such that it carries the information of the object requested by the user. In this example, I will be using a very basic form of a custom exception.

package com.exceptions;
public class InvalidOperationException extends Exception
private String msg;
public NumberFormatException(String message)
this.msg = message;
public String getMsg()
return this.msg;

This is an custom exception that when a user creates needs to pass a message that should be stored. Note that how you handle exceptions on the server is not in scope of this article, but one day I will post my recommended practices of managing Exceptions.

This code snippet shows how do I raise the exception.

public void doOperation() throws InvalidOperationException
// Will throw an exception
int a = 2 / 0;
catch(Exception ex)
throw new InvalidOperationException(“this is some error I should get in Flex.”);



Flex Code

If you use RemoteObjects then you can make calls to remote destinations and add responders to the AsyncObject. The responder allows you to provide a fault handler which should be coded as:

public function fault(e:Object):void
var evt:FaultEvent = e as FaultEvent;
var errorMessage:ErrorMessage = evt.message as ErrorMessage;“message : ” + errorMessage.rootCause.msg);

Note that I am using the mx.messaging.messages.ErrorMessage class. When you raise an exception on the back-end that exception is placed in the root-cause of the ErrorMessage object. Out of the box if you try to access the rootCause.message property, you will get the some default message. But, this is not so much helpful. Many a times, you may need things like the stack trace or additional information about the error which then is passed along in the object as the property that you have defined in the code above “msg”.

My sample here only takes care of checked exceptions. There is still a conversation/thread that I am working on to understand how can I trap the un-checked exceptions and pass along additional context to the Flex client. But, this is a back-burner because I believe in code that does not raised any un-checked exceptions.

Bingo!! Have fun with errors.