« August 2007 | Main | October 2007 »

September 2007 Archives

September 1, 2007

Introducing VEGAS, an Actionscript 3 / 2 and SSAS framework - Global event-listeners and addEventListener for ALL events

Vegas is an OpenSource Framework based on ECMASCript that can be used both on Actionscript 3, Actionscript 2, and Server Side Actionscript and it provides a lot of cool feature to help developers creating RIAs.

The main core features of VEGAS are:

  • AS3, SSAS and AS2 Framework.
  • Unit Test based on ASTUce.
  • AS2 librairie is “MTASC compatible” !
  • Ready to use EDEN.
  • SSAS library based on Core2 and EDEN.
  • ADT (Abstract Data Type) package in AS2, AS3 ans SSAS libraries (queue, map, collections, stack, bag, iterator, ... polymorphism with JAVA Collections)
  • Events package : Event’s model based on W3C Dom2 with bubbling, capturing etc + FrontController pattern.
  • String tools : JSON, Eden serialization/deserialization, Lunh, wildcard, StringFormat...
  • Tools : Serializer, Copier, ArrayUtil, etc..
  • Logging model to use SOS console, LuminicBox FlashInspector, XPanel... AS2 logging model use polymorphism with mx.logging package in AS3 framework.
  • Pattern MVC : 3 implementations with a FrontController or IView, IModel and IController or IObservable/IObserver implementation.
  • Pattern Visitor interfaces (IVisitor, IVisitable).
  • Factory tools (DisplayObjectFactory, ContextMenuItemFactory...)

With Vegas you can use 3 other libraries based on Vegas : PEGAS, ASGard, Lunas. This 3 libraries are in the SVN of VEGAS.

PEGAS

  • Color Manipulation.
  • draw API tools (ArcPen, BezierPen, RectanglePen, Canvas....)
  • Transitions package (Tween, ..)
  • geom package with flash.geom polymorphism for FP7 & FP8 and other tool class (Vertex, Vector2, Vector3, Quaternion...)
  • Maths tools (Prime, Factor, Range...)
  • Process package (Sequencer & Action).
  • UI package. (KeyValidator, DoubleClick...)

ASGard

AS2 version :

  • AS3 Framework polymorphism.
  • Display package (Bitmap, DisplayObject, DisplayLoader, FlashPaperLoader, VideoDisplay, ZoomDisplay...)
  • Loader package (URLLoader, JSONLoader, EdenLoader, StyleSheetLoader...)
  • Remoting package with no Macromedia Framework’s dependencies.
  • Localization and system package
  • Configuration model.
  • Text Package (StyleSheet, ...) like AS3 flash.text framework.

In the SSAS(Server Side ActionScript) version for Flash Media Server :

  • The same Remoting class like AS2 and AS3 libraries.
  • asgard.server.Application class to creates your FMS application based on VEGAS.
  • asgard.server.Gateway class to creates a Gateway based on the FrontController of Vegas (used AS2 Event in the client application and send this events with the NetConnection.call method directly in the server side FrontController.

LunAS

This library based on ASGard and VEGAS to create components. It's not a component of framework but a framework to make components !!

Use examples in AS2/bin/test/lunas to test this framework.

  • bar package : Progressbar, scrollbar...
  • button package
  • container package : SimpleContainer, ListContainer, ScrollContainer, AutoScrollContainer, MatrixContainer...
  • cell package : cells in list and datagrids
  • list package : List components based on containers and with a polymophism with mx package of macromedia.
  • shape package : all shape components.
  • stepper package : basic implementation to create Stepper components.
  • text package : Label, TextArea and TextInput abstract implementation.

Global event-listeners

In some rare cases (especially for debugging purposes) it might be useful to add an event listener that catches all events that are thrown in your application.

In order to achive this, you do not need to register the event listener separately for each event that might be triggered, but use the addGlobalEventListener() instead :

import vegas.events.EventDispatcher ; import vegas.events.EventListener ;

import test.events.DebugHandler ;

var disp:EventDispatcher = new EventDispatcher() ;

var global:EventListener = new DebugHandler("global") ;

// register the global event listener.
disp.addGlobalEventListener( global ) ;

disp.dispatchEvent( "onLogin" ) ;
disp.dispatchEvent( "onLogout" ) ;


// unregister the global event listener.
disp.removeGlobalEventListener(global) ;

disp.dispatchEvent( "onLogin" ) ;
disp.dispatchEvent( "onLogout" ) ;

This event listener will now be called for both events, the onLogin and the onLogout event.

However, you should be aware, that global event listeners are processed after all local event listeners handled the event.

The removeGlobalEventListener() method unregister the global event listener.

In VEGAS you can apply a global event listener with the method addEventListener and the magic type : "ALL"

import vegas.events.EventDispatcher ; import vegas.events.EventListener ;

import test.events.DebugHandler ;

var disp:EventDispatcher = new EventDispatcher() ;

var global:EventListener = new DebugHandler() ;

// register the global event listener.
disp.addEventListener( "ALL", global ) ;

disp.dispatchEvent( "onLogin" ) ;
disp.dispatchEvent( "onLogout" ) ;


// unregister the global event listener.
disp.removeEventListener( "ALL", global ) ;

disp.dispatchEvent( "onLogin" ) ;
disp.dispatchEvent( "onLogout" ) ;

NB : In this examples, the DebugHandler class is an easy EventListener implementation.

import vegas.events.Event ; import vegas.events.EventListener;

/**
* The DebugHandler class.
*/
class test.events.DebugHandler implements EventListener
{

/**
* Creates a new DebugHandler instance.
*/
public function DebugHandler(){}

/**
* Handles the event.
*/
public function handleEvent(e:Event)
{
trace( this + " handled event : " + e.getType() ) ;
}

/**
* Returns the String representation of the object.
* @return the String representation of the object.
*/
public function toString():String
{
return "[DebugHandler]" ;
}

/**
* The internal private name property of this instance.
*/
private var _name:String ;

}


Conclusion

Vegas actually implements a lot of features that any other fameworks actually implement in actionscript. It's inspired by great architectures like J2EE, Apple notification center for the EventDispatcher and introduces the ForntController Pattern and Pattern Visitor interfaces. In this post you can see the "General event listener", the method to listen for all event in an application, this is only a little part of the Event Model introduced by Vegas. I think that the Event model it's the most important feature of the framework. In the next post, I will show you the other's important method and the implementation of some pattern.

September 9, 2007

An open source alternative to Adobe LiveCycle Data Services: Granite Data Services

Adobe LiveCycle Data Services ES, formerly called Flex Data Services (FDS), provides data services such as remoting, data push, publish and subscribe for Flex applications. With LCDS you can integrate flex with J2EE infrastructures and a previuos post on our blog shows an example: LiveCycle Data Services and Hibernate integration in Flex RIA applications.
There are a lot of open source projects around flex, flash and AMF, and, on java side, GraniteDS is one of the most promising.
It's developed under the LGPL and proposes itself as an alternative to Adobe® LiveCycle® (Flex™ 2) Data Services for J2EE application servers.
GDS is still in an early development phase, with a 0.3 version released on july 30, while, at the time of writing, the 0.4 one is in a release candidate state; despite this, it's rather stable and you can safely test it in non critical production environment as its home page suggests.
Here they are the features already implemented and the planned ones; this list is continuously updated


  • Full AMF3 support. See GDS AMF3 documentation.

  • EJB3 services with transparent externalization mechanism and lazy initialized ActionScript 3 beans (Entity Beans / Hibernate). See EJB3 Services and Externalizers and Lazy Initialization.
  • EJB3 Entity Bean to ActionScript 3 classes code generator. See AS3 Generation.

  • Spring services. See documentation on Spring Services.

  • POJO services (remote calls to simple Java classes that expose public methods). See Pojo Services.
  • (planned) Data push. A Comet-like implementation with AMF3 data polling over HTTP (event/listener based architecture).

  • (planned) Entity repository: a client side entity repository that ensures uniqueness (only one instance of each entity is present in the flash VM), weakness (only currently bound objects are kept in memory), and that acts as a services frontend (all server calls/events are managed by this central component). This will be loosely inspired by Cairngorm.

  • (planned) Seam integration: a reliable GDS/Seam integration with full scopes (at least conversation) support.
  • (planned) A set of Flex components suitable for complex data structures.

A key feature, implemented in version 0.3, is the support for setCredentials, setRemoteCredentials and logout methods of RemoteObject, more information in the release notes: http://www.graniteds.org/confluence/display/DOC03/Documentation+-+0.3

They provides various demos which you can you use importing them as new eclipse projects:


Moreover a live demo that shows Granite DS in action is available.

If you are interested in testing your LCDS application with Granite Data Services you have to make some changes according to the good documentation ready to help you; however you should check if all the features you need are implemented.
Granite DS is a promising project and the development is going on quite fast, but it still misses some important functionalities like messaging services and data push (planned feature) so by now LCDS is a must in a stable production enviroment, but i can suggest to keep an eye on GDS for the future.

September 18, 2007

Notes from the Oreilly RailsConf2007 - First day

The RailsConf Europe 2007 is a three day event dedicated entirely to Ruby on Rails and organized by O'Reilly.

railsEurope.gifA lot of intresting sessions are available at the Ruby on Rails conference 2007 in Berlin. In this post I'll write some notes about sessions I've partecipated on the first day of the conference.

Making Rails more (Artificially) Inteligent
Imagine a Ruby on Rails appliction that implements Artificialy Inteligent and her possible implementation, starting from a simple spam filtering to a problem solving. Sergio Espeja (Universitat Pompeu Fabra) and Santiago Bel (bee.com.es) has demontrated implementation of available open source AI Algorithms, such as Bayesian Networks, Naive Bayes Classifier, Genetic Alghorithms and its uses.

ActiveRecord and Service Data Objects: Adding New Data Models Beneath Your Rails Apps
Doug Tidwell (IBM) showed how easy is to implement Service Data Objects (SDO) to enable
ActiveRecord to access data source, such as XML files, web services, and LDAP directories. ActiveRecord is a great way to integrate a relational database into Rails application but in this session we discovered that it's very extensible to other data sources in the same way of a database.

JRuby on Rails: A Path to Adoption
In a world were deployment of dozens of servers is a painless Thomas Enebo and Charles Nutter (Sun MIcrosystems, Inc.) demonstrate how to deploy JRuby in Rails application, how to integrate Rails with Java services and APIs, and how to effetively and easily manage JRuby on Rails apps using clustering and Java Management Extensions.

Anchoring Trust: Rewriting DNS for the Semantic Network with Ruby and Rails
Thanks to Eleanor McHugh and Romek Szczesniak (Games With Brains), two well-known London-based Ruby hackers, for the discussion taked about Semantic DNS and Rails. With a basic method explained how to implements a crazy DNS hyperlink and they have invited to the party of this criteria. Only this little Rubytastic critters are hyperlinks on steroids and the newtwork will never be the same again.

Keep updated for the second day's report.

September 19, 2007

Notes from the O' Reilly RailsConf Europe 2007 - Second day

The first day was simple amazing. Great people, sessions and food ;) Berlin is a wonderful place. These are my impressions of the second and last day of the conference.

railsEurope.gifMy second day at the Ruby on Rails conference 2007 in Berlin, was very intresting and I've learned about how to improve webapp in Europe, Slingshot and some testing tips.

Building WebApps in Europe: Economy, methodology, tips
In this session Nicolas Paton (Bloogk) describe some tips and methodology for people intent do build a webapp. They sostain that a webapp dont have to be a new Google to bring wealth and happiness to their creators, so invite anyone to open your mind to new markets. Another important point of view is the Design, not only the graphical design but technical design through tests, and economical design

Creating Hybrid Web and Desktop Applications with Rails and Slingshot
During the session of Luke Crawford (Joyent) i have said how to implement a synchronized online and offline application with Slingshot. Slingshot provide an ActiveRecord transport layer allowing easy customization of the data that gets synced to an online application. With the addition of about thirty lines of code, a Rails application can sync data from client to server. With another thirty lines of code you synchronize have file-based data. The framework also provides an extensible drag and drop abstraction layer.

Browser-based Testing of Massive Ajax-using Rails Applications with Selenium
To create a web application mostly similar to a normal desktop application we need a very good testing framework for the client side and not only for the server side. Till Vollmer (Codemart GmbH) spoke about Selenium, an open source framework that allows running acceptance tests in the browser directly. Recorded or scripted scenarios can be played back and the expected result verified. While this is very straight forwarded with normal page-based applications, without dynamic Ajax calls it is relatively tricky to implement tests for Ajax-based applications with a lot of dynamics and user interaction like drag and drop.

Continuous Validation: Pursuing Error-free Apps
Another important session about testing and validation has taked by Dane Avilla. He discuss the importance of output validation and demonstrate how to use WATIR and Rails filters along with a number of helpful open source tools -- JSLint, OpenSP, the W3C's CSS Validator -- to be sure "rake test" catches output errors long before they reach a client browser.

Unfortunately I had the flight sceduled at 5.35pm so can't see the last sessions.

September 28, 2007

Automating ActionScript 3 classes generation from Java Beans in a LiveCycle Data Services context

In a Flex application that uses LiveCycle Data Services or the previous Flex Data Services to manage data from a remote server there is the requirement that Flex domain model classes have to match Java domain model, in structure, properties and types. Usually it means that for each Java class that is supposed to be configured as a remote alias one should write down an ActionScript class with the same properties, just as described in the Adobe livedocs at Livedocs
The documentation provides a mapping for ActionScript data types and Java data types and specifies that Java classes are dealt with through the Java Beans specification, that can be downloaded here: Javabeans

The Java class is serialized and all of its public properties and the ones with getter and setter methods are serialized. All other properties are not, including the ones without a getter. There is one thing related to the Java beans that worths a bit of attention, and it is bean attribute names that start with a lower case character followed by a upper case character: their getter and setter methods will have get/set followed by at least two upper case characters, for example "aFoo" will have "getAFoo" and "setAFoo". When the Java introspection mechanism, described in the above specification, finds these kind of properties, it will infer that the property is called "AFoo". That implies that inside the ActionScript class that matches the Java bean the property has to be called "AFoo", otherwise it will not be recognized. This usually translates on the flash log in a "ReferenceError: Error #1056: Cannot create property AFoo on [...]".

Consider the case where all of the properties of a class are declared in Java with a lower case followed by an upper case, one could easily convert into an ActionScript class that follows the same naming convention and, at runtime, there will be an empty object, with the right type but no contents; the ReferenceErrors in the flashlog will point out the problem and the solution, in this case, is to call ActionScript properties starting with two upper case characters: "AFoo".

Iin an enterprise application there can be many Java bean classes to be converted to ActionScript counterparts, a simpler way of solving this and possibly other problems related to Java to ActionScript conversion would be the use of an automatic tool. At the time of writing this blog post I personally did not find a tool that performs the conversion, a tool that can be easily integrated into an IDE, like Eclipse, or used as an Ant task, thus I'm considering writing one myself. The backend of this tool would use java.beans.Introspector to get the java.beans.PropertyDescriptor for each property of the bean, map the Java types to the ActionScript ones and generate the required imports. I'll keep the blog updated with progress on the tool, as well as interesting parts of the source code.

About September 2007

This page contains all entries posted to Comtaste Consulting | Enterprise RIA consulting and development in September 2007. They are listed from oldest to newest.

August 2007 is the previous archive.

October 2007 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.33