Flex as a J2EE MVC Tier
I began my web programming life using Perl and PHP and I don’t like the idea of becoming a language snob, however, I have to admit I have been somewhat of a Java purist over the past couple of years in particular and I saw no reason to make an exception for the presentation tier.
I was thinking the other day about that saying: ‘When your only tool is a hammer, everything looks like a nail‘. This came up when I was looking at working AJAX functionality into a Spring MVC web application. I had already worked JQuery into the UI for effects and to speed up querying the DOM. I had an custom tag library called SpringLayout, which I was using to integrate error messages and speed up validation responses. I had Yahoo! tabs going for client side tabs, and I started thinking about how difficult this application would be to maintain, particularly if that person wasn’t me.
What I was really after was a Rich Internet Application (RIA). Because Java is my hammer, the RIA looked like a nail. But I started wondering whether there might be an easier way to achieve the rich user experience without sacrificing the well tested and proven Java application… along came Flex 3. Flex uses a component based approach based on ActionScript. I’m not going to go into the details of the Flex application framework, except to say that writing RIAs is extremely simple and intuitive using Flex and flex builder.
One of the interesting side effects of moving to a non-Java presentation tier technology is that you quickly become aware of areas where you have allowed application logic to bleed into the presentation tier. Without some type of artificial barrier, such as having to translate objects into ActionScript, it is quite possible for POJO based applications to leak some of their business logic out into the MVC layer. Kept to a minimum this is not the end of the world, however I prefer to have a complete separation, particularly since we often have to expose business services to automated clients.
BlazeDS has been an interesting tool in coming to terms with Flex as the client for my java based applications. It is an open source offering from adobe, allowing Flex clients to make RPC calls or access JMS queues and topics and has recently been released as a Beta. It performs the translation to ActionScript Message Format (AMF) transparently, greatly easing the effort in developing a transport and translation service for your Flex client. It is essentially a cut down version of the Adobe LiveCycle Server.
I will be blogging in more detail on the technical issues I have come across in coding in Flex and using Flex Builder as well as plugging in BlazeDS.