« February 2009 | Main | April 2009 »

March 2009 Archives

March 2, 2009

Dao-Ext, an open source ActionScript Value Objects and Data Access Objects generation tool

How many times during your ActionScript, Flex and AIR development you've forced to spend several time to create ActionScript Value Objects and Data Access Objects for your the data access login of your application.
We at Comtaste have released an open source AIR tool (under GPL) to reduce the development time: Dao-Ext is come!

Dao-Ext is a tool that auto-generates ActionScript VOs and DAOs starting from a local SQLite databse and that will make your life easier when developing Adobe AIR Applications which use local persistent data.
All you need is to donwload and launch Dao-Ext AIR tool, select your local database file and let Dao-Ext does the job for you.

In this first release Dao-Ext simply creates VOs and DAOs for database tables. The tool allows you to choose namespaces to use for classes generation.
In the next upcoming release will give you the ability to fully customize the VOs and DAO creation process.

You can download Dao-Ext from Google Code: http://code.google.com/p/dao-ext/!

March 6, 2009

Installing and using Weborb.NET platform for Flex clients

Weborb for .NET is one of the best platform to connect Flex, Flash, AJAX and Silverlight clients with .NET objects, XML Web Services, native operating system resources and rich media streams (audio and video). In this post I will show you how to install and start up this platform on XP Professional with IIS 6.0.
First of all you have to install .NET 2.0 Framework on yours machines, following the steps below :

- open a Dos Shell
-go to the directory that contains .NET 2.0 installation files ( usually is C:\WINDOWS
\Microsoft.NET\Framework\v2.0.50727).
- Execute the command: aspnett_regiis -i

After this operation you can proceed with the weborb installation.

In order to download WEBORB platform from MIDNIGHT CODERS web site, you have to register yourself (it is FREE!) and after this you will be able to save WeborbSetup3.6.0.3.zip file on your computer. Now you have to unzip that file and run setup; after few seconds you are ready to test your WEBORB Installation.

Now open your browser and go to http:\\localhost\weborb30. At this address you can find the start page of WEBORB .NET platform.

paginaIniziale.jpg


First of all you can see a lot of example of what you can do with this platform in the section “Example” of the main Menu, but one of the most interest function is the Deployment. In this section you can create your server-side application in two different ways:

paginaDeploy.jpg


The first way is to automatically deploy weborb library in an IIS Virtual directory. It is very simple, in fact is enough to drag and drop the virtual directory from the list on the left to the list on the right, and, after a few seconds, you will have all the configurations files ready in the destination directory.

The second way is to deploy manually the weborb library following the steps below:

-Copy the following files/folders from the default Weborb installation directory to the
corresponding folders in the target virtual directory:

/Licenses/weborblicense.key.config
/bin/weborb.dll (main WebORB assembly)
   /bin/Npgsql.dll (a database driver used by WebORB Data Management)
   /bin/MySql.Data.dll (a database driver used by WebORB Data Management)
   /bin/Mono.Security.dll (a database driver used by WebORB Data Management)
   /weborb.config (product configuration file)
   /weborbee.exe (WebORB Enterprise Edition standalone server)
   /weborbee.exe.config (WebORB Enterprise Edition executable config)
   /Applications (WebORB messaging applications home)
   /Global.asax (includes WebORB messaging server startup and shutdown code. Merge the
contents if the file already exists)
   /diagnostics.aspx (product diagnostics utility)
   /WEB-INF (Flex configuration files home)
   /weborbassets (Code generator stylesheets home)
   /services (WebORB web services, contains backend support for WDMF plugin for Flex Builder)
   /weborb.js (required only for the AJAX clients)

- Add the following XML configuration to web.config in the target virtual directory:

<configuration>
<system.web>
<httpHandlers>
<add verb="*" path="weborb.aspx" type="Weborb.ORBHttpHandler"/>
<add verb="*" path="codegen.aspx" type= "Weborb.Management.CodeGen.CodegeneratorHttpHandler"/>
</httpHandlers>
</system.web>
</configuration>

- Grant Write permission to the user account ASP.NET uses for the following files and directories:

   /weborb.config (required only if making configuration changes from the console)
   /logs (required only if logging is enabled)
   /weborbassets/codegen (required only if codegen is used in the console)
   /weborbassets/uploads
   /weborbassets/wdm
   /weborbassets/wdm/output
   /*.mdb (required only if writing data back on the server in some examples)


Another very important function in the main menu is Management where you can test our remote components without any dedicated client application!

paginaManagement2.jpg

Next time I will show you a small example with a Flex client.

March 13, 2009

Messaging from Java to Flex without JMS

With BlazeDS/LCDS you can send messages to and receive messages from a server side destination thanks to Messaging Services and their client-side API.

In your messaging configuration you can use a ActionScript Adapter:
<adapter-definition id="actionscript" class="flex.messaging.services.messaging.adapters.ActionScriptAdapter" default="true" />

or a JMS Adapter:
<adapter-definition id="jms" class="flex.messaging.services.messaging.adapters.JMSAdapter"/>

that integrates Flex messaging with Java Message Service destinations.

If you don't have JMS or you don't want to use it in your web application you can send messages from Java to Flex in a very simple way.

First of all you should enable the ActionScript adapter and create your destination without additional parameters:


<destination id="actionscriptMessaging">

</destination>

In your Flex application you have your Consumer:


<mx:Consumer id="consumer"
destination="actionscriptMessaging"
message="messageHandler(event);"
fault="faultHandler(event);"/>

that is subscribed to the previous destination so that it can receive messages:


consumer.subscribe();

On the Java side, inside the context of the web application in which LCDS/BlazeDS runs, you can use these lines of codes to send messages to your Flex Consumer:


AsyncMessage msg = new AsyncMessage();
msg.setTimestamp(new Date().getTime());

msg.setClientId("JavaMessageProducer");
msg.setMessageId("JavaMessageId");

//destination configured in messaging-config.xml
msg.setDestination("actionscriptMessaging");

msg.setBody("Message from Java!");

//you can set custom message headers
msg.setHeader("headerParam1", "value1");
msg.setHeader("headerParam2", "value2");

//send message to destination
MessageBroker.getMessageBroker(null).routeMessageToService(msg, null);

This is a solution suitable for uni-directional messaging, if you want to use a bi-directional messaging system it's convenient to use JMS.

March 27, 2009

Understanding and improving Flex bindings

Data binding is the magical process by which changes in a data model are instantly exposed to views. It works because of the Flex framework that generates a lot of code for you under the hood.

Let's see what flex does when we set a property [Bindable] by using the setter and getter method like this:

public class MyComponent
{

private var _myProp:Object;

[Bindable]
public function get myProp( ) : Object
{
return _myProp;
}

public function set myProp( value:Object ) : void
{
_myProp = value;
}

}

Now when you set the myProp to some value:

var myCompInstance:MyComponent = new MyComponent( );
var myPropToSet:Object = new Object( );
myCompInstance.myProp = myPropToSet;

you are going to invoke the statement "function set myProp( value:Object )".
But Flex will do something different.
First of all it will compare the new value, myPropToSet with the last inserted _myProp, by invoking the getter function, and if the value result will be the same, the setter will not be invoked.
All of this because you have marked the property as [Bindable].
So if run a code like this:

myCompInstance.myProp = myPropToSet; <-- only this will be set
myCompInstance.myProp = myPropToSet;
myCompInstance.myProp = myPropToSet;

only the first value will be set.
So if you have the necessity to reset a value on a bindable property you have to define your custom binding:

[Bindable(event="myCustomChangeEvent")]
public function get myProp( ) : Object
{
return _myProp;
}

public function set myProp( value:Object ) : void
{
_myProp = value;
dispatchEvent( new Event( "myCustomChangeEvent" ) );
}

Now you can set the property every time you want and any item who is watching will be regularly notified.

About March 2009

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

February 2009 is the previous archive.

April 2009 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