Archive for January, 2007

Grey Line

My Dell laptop is dying and I had to make a choice - which small screen laptop to buy next. After having two issues with motherboards in my last two laptops Dell is out, and I was choosing between Lenovo X60 (12″) and MacBook Pro (13″) with  dual boot – OSX or Windows. As a professional enterprise developer I was inclined to stay with PC, and these couple of youtube videos have confirmed my decision – Wintel notebook.

But I’m still waiting till Lenovo will start shipping their notebooks with Windows Vista (today’s the first official Vista day). That’s why I decided to look at the Windows Vista home page .  It shows a nice little presentation on  Vista using…Flash Player from their rival Adobe. This is a clear indication that Flash Player is a de-facto standard when it comes to delivering multimedia. FLash Player’s ubiquity forced Microsoft bite the bullet and use it instead of their Windows Media Player. That’s why Adobe Flex and not WPF/E should be a tool of choice for rich internet application development…at least for another couple of years.

Yours truly,
Yakov Fain

Comments (8)

 

Grey Line

Several years ago I wrote an article on using abstract classses and interfaces in Java . Back than I was absolutely sure that writing object-oriented code is a must. These days, I’m using yet another language called ActionScript 3 (AS3), which supports all OOP paraphenalia plus has provisions for dynamic data types. This article illustrates my up to date vision of OOP with and without interfaces. OK, let’s go.

You know the drill: a language is called object-oriented if it supports inheritance, encapsulation and polymorphism. The first two notions can be easily defined:

• Inheritance allows you to design a class by deriving it from an existing one. This feature allows you to reuse existing code without doing copy and paste. AS3 provides the keyword extends for declaring class inheritance, for example:

package com.theriabook.oop{
public class Person {
var name:String;
}
}

package com.theriabook.oop{
public class Consultant extends Person{
var dailyRate:Number;
}
}

package com.theriabook.oop{
public class Employee extends Person{
var salary:Number;
}
}

Listing 1. The ancestor and two descendents

• Encapsulation is an ability to hide and protect data. AS3 has access level qualifiers such as public, private, protected and internal to control the access class variables and methods. In addition to a Java-like public, private, protected and package access levels, in AS3 you can also create namespaces that will give you yet another way of controlling access to properties and methods. However, if Java enforces object-oriented style of programming, this is not the case with AS3, because it’s based on the scripting language standard. Object-oriented purists may not like the next code snippet, but this is how HelloWorld program may look in AS3:

trace(“Hello, world”);

That’s it. No class declaration is required for such a simple program, and the debug function trace() can live its own class-independent life, as opposed to Java’s println() doubly-wrapped in the classes System and PrintStream. You can write your own functions, attach them to dynamic objects and pass them as parameters to other functions. AS3 supports regular inheritance chain as well as so-called prototype inheritance when you can add new properties to the class definitions, and they will be available to all instances of this class. Moreover, you can disable validation of the properties and methods during compilation by turning off “strict” mode. In Java, behind every object instance there is an entity of type Class. This is not an object itself, but it’s placed in memory by class loaders.

Program Design with Interfaces and Polymorphism

As in Java, AS3 interfaces are special entities that define the behavior (methods) that can be implemented by classes using the keyword implement. After explaining crucial for OOP interfaces, we’ll discuss how to write generic code even without their.

To illustrate how you can design AS3 programs with interfaces, let’s work on the following assignment:

A company has employees and consultants. Design classes to represent people working in this company. The classes may have the following methods: changeAddress, giveDayOff, increasePay. Promotion can mean giving one day off and raising the salary by a specified percentage. For employees, the method increasePay should raise the yearly salary and, for consultants, it should increase their hourly rate.

First, we’ll add all common methods that are applicable to both employees and consultants to the class Person.

package com.theriabook.oop {
public class Person {
var name:String;

public function changeAddress(address: String): String {
return “New address is” + address;
}

private function giveDayOff(): String {
return “Class Person: Giving an extra a day off”;
}
}
}
Listing 2. The Ancestor class: Person

In the next step, we’ll add a new behavior that can be reused by multiple classes: an ability to increase the amount of a person’s paycheck. Let’s define an interface Payable:

package com.theriabook.oop
{
public interface Payable
{
function increasePay(percent:Number): String;
}
}

Listing 3. Interface Payable

More than one class can implement this interface:

package com.theriabook.oop
{
public class Employee extends Person implements Payable
{
public function increasePay(percent:Number):String {
// Employee-specific code goes here …
return “Class Employee:Increasing the salary by “+ percent + “%\n”;
}
}
}
Listing 4. AS3 class Employee implementing Payable interface

package com.theriabook.oop
{
public class Consultant extends Person implements Payable {

public function increasePay(percent:Number): String{
// Consultant-specific code goes here …
return “Class Consultant: Increasing the hourly rate by ” + percent + “%\n”;

}
}
}
Listing 5. Class Consultant implementing Payable

When the class Consultant declares that it implements interface Payable, it “promises” to provide implementation for all methods declared in this interface – in our case it’s just one method increasePay(). Why is it so important that the class will “keep the promise” and implement all interface’s methods? An interface is a description of some behavior(s). In our case the behavior Payable means existence of a method with the signature
boolean increasePay(int percent).

If any other class knows that Employee implements Payable, it can safely call any method declared in the Payable interface (see the interface example in class Promoter).

In Java, besides method declarations, interfaces can contain final static variables, but AS3 does not allow in interfaces anything but method declarations.

Interfaces is yet another workaround for the absence of multiple inheritance. A class can’t have two independent ancestors, but it can implement multiple interfaces, it just needs to implement all methods declared in all interfaces. One of the way to implement multiple ingeritance (we often use but do not recommend – use at your own risk) is to use “include” statement with complete implementation in all classes implementing interface:
public class Consultant extends Person implements Payable {
include “payableImplementation.as”
}
public class Employee extends Person implements Payable {
include “payableImplementation.as”
}

For example, a class Consultant can be defined as follows:

class Consultant extends Person
implements Payable, Sueable {…}

But if a program such as Promoter.mxml (see below) is interested only in Payable functions, it can cast the object only to those interfaces it intends to use, for example:

var emp:Employee = new Employee();
var con:Consultant = new Consultant();
var person1:Payable = emp as Payable;
var person2:Payable = con as Payable;

Now we’ll write a MXML program Promoter, which will use classes Employee and Consultant defined in the Listing 4 and 5. On the button click it’ll create an array with a mix of employees and consultants, iterate through this array and cast it to Payable interface, and then call the method increasePay() on each object in this collection.

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute”>
<mx:Label y=”10″ text=”Inheritance, Interfaces and Polymorphysm” width=”398″ height=”35″ fontWeight=”bold” horizontalCenter=”-16″ fontSize=”16″/>
<mx:Button x=”93″ y=”66″ label=”Increase Pay” width=”172″ fontSize=”16″ click=”startPromoter()” id=”starter”/>
<mx:TextArea x=”26″ y=”114″ width=”312″ height=”133″ id=”output” wordWrap=”true” editable=”false” borderStyle=”inset”/>

<mx:Script>
<![CDATA[
import com.theriabook.oop.*;
function startPromoter():void{
output.text="Starting global promotions...\n";

var workers:Array = new Array();
workers.push(new Employee());
workers.push(new Consultant());
workers.push(new Employee());
workers.push(new Employee());

for(var i: int = 0; i < workers.length; i++) {
// Raise the compensation of every worker using Payable
// interface
var p: Payable = workers[i] as Payable;
output.text+= p.increasePay(5);

//p.giveDayOff(); would not work. Payable does not know
// about this function
}

output.text+=”Finished global promotions…”;
}
]]>
</mx:Script>
</mx:Application>

Listing 6. Promoter.mxml

The output of this program will look as follows:


The line p.increasePay(5); in the listing above may look a little confusing: how can we call a concrete method increasePay on a variable of an interface type? Actually we call a method on a concrete instance of the Employee or a Consultant object, but by casting this instance to the type Payable we are just letting the AVM know that we are only interested in methods which were declared in this particular interface.

• Polymorphism – when you look at our Promoter from Listing 6, it looks like it calls the same method increasePay() on different types of objects, and it generates different output for each type. This is an example of polymorphic behavior.

In the real world, array workers would be populated from some external data source. For example, a program could get the person’s work status from the database and instantiate an appropriate concrete class. The loop in Promoter.mxml will remain the same even if we’ll add some other types of workers inherited from the class Person! For example, to add a new category of a worker – a foreign contractor, we’ll have to create a class ForeignContractor that implement the method increasePays and might be derived from the class Person. Our Promoter will keep casting all these objects to the type Payable during the run-time and call the method increasePay of the current object from the array.

Polymorphism allows you to avoid using switch or if statements with the type checking operator is. Below is a bad (non-polymorphic) alternative to our loop from Promoter.mxml that checks the type of the object and calls type-specific methods increaseSalary() and increaseRate() (assuming that these methods were defined):

for(var i: int = 0; i < workers.length; i++) {
var p: Person = workers[i] as Person;
if (p is Employee){
increaseSalary(5);
} else if (p is Consultant) {
increaseRate(5);
}
}

Listing 7. A bad practice example

You’d need to modify the code above each time you add a new worker type.

Polymorphism without interfaces

If this would be a Java article, I could have patted myself on the back for providing a decent example of polymorphism. But I’d like to step into a little bit dangerous territory: let’s think of a more generic approach – do we even need to use interfaces to ensure that a particular object instance has a required function like increasePay? Of course not. Java has a powerful introspection and reflection mechanism, which allows to analyze which methods exist in the class in question. It’s important to remember though, that in Java object instances have only those methods that were defined in their classes (blueprints). This is not the case with AS3.

There is yet another urban myth that reflection is slow, and you should use it only if you have to. But this consideration is not valid for programs that run on the client’s PCs, because we do not have to worry about hundreds of threads competing for a slice of time of the same server’s CPU(s). Using reflection on the client is fine. Even on the server, a proper combining of reflection with caching allows avoiding any performance penalties.

AS3 provides very short and elegant syntax for introspection, and we’d like to spend some time illustrating polymorphism without typecasting and strict Java-style coding.

Let’s re-visit our sample application. Workers have pay and benefits and vacations, consultants have hourly pay. But retirees may have some other forms of receiving pension, board of directors might have pay with no benefits – are they workers? No they are not, and their objects may not necessarily implement Payable interface, which means that the typecasting from Listing 6 would cause a run-time exception.

How about raising the compensation of every Person even if it does not implement Payable? If one of these objects will sneak into the array of workers, simple casting to Payable show below will throw an exception

Payable p = Payable(workers[i]);

Let’s re-write the loop from Listing 6 as follows:

for(var i:uint = 0; i < workers.length; i++) {
var p:* = workers[i]["increasePay"];
output.text+=p==undefined?”no luck”:p(5);
}

This short loop deserves explanations. First, we’ve declared a variable p of type *. Using an asterisk a bit more open than var p:Object; as it allows the variable p to have a special value of type undefined, which is used in the above code sample.

Let’s dissect the following line:

var p:* = worker[i]["increasePay"];

It means, “Get a reference to the function increasePay() from the array element workers[i]. You may ask, why do you use brackets around the increasePay instead of the dot notation? The reason being that dot notation would ask the compiler to find and validate this function, while the brackets tell compiler not to worry about it: the program will take care of this little something inside the brackets during the runtime.

Basically, this single line above performs the introspection and gets a pointer to the function increasePay for the future execution in the next line:
output.text+=p ==undefined?”no luck":p(5);

If this particular element of the workers array does not have increasePay defined (its class must be declared as dynamic), add “no luck” to the text field, otherwise execute this object’s version of increasePay passing the number five as its argument. The line above still has a potential problem if the class does not have the function increasePay, but has a property with the same name. The bulletproof version looks like this:

output.text+=!(p is Function)?"no luck":p(6);

Let’s emphasize again: this method increasePay does not have be defined in any interface.

Java programmers would call this a wild anarchy. Of course, adhering to strict rules and contracts in Java leads to more predictable code and less surprises during the run-time. But modern Java moves toward dynamic scripting, added implicit typecasting, run-time exceptions, etc. Overuse of interfaces, private, protected and other “nice and clean object-oriented techniques” does not promote creative thinking of software developers. By the way, protected variables is another weird thing in OOP.
Summary

Now raise your hand if you are a Java programmer and after reading this article you are thinking to yourself, “Hmm, may be ActionScript 3 is not too bad and I should take a look at it ?”.

Now, stand up if you are thinking, “Java rules, the rest of programming languages sucks”.

ActionScript 2 programmers can remain seated, but might want to reconsider the way they program.

Yours truly,
Yakov Fain

Comments (4)

 

Grey Line

I think it is time for new YouTube type of service based on Flex/Flash platform. That one has to take on making application service for masses. That’s right – time to take on big guys like SalesForce.com (1st step) and SAP (next target). Any takers?

Flex is a rich client for new incarnation of client/server platform. This time around it is “rich client/Web paltform”. And flash/flex AMF3 and rtmp protocols that offer unique advantages that are not well known to decision makers. As a matter of fact, most decision makers do not know how bad XML might be for business applications – till it is too late.

Do not take my word for it – check out example on James Wards site ( http://www.jamesward.org/census/ ) and plug in few numbers – like increase number of rows to favorite 20,000 or build your own test and increase number of columns.

I spent last week doing small pilot for yet another SOP (save our project) case. While fixing client-side performance and memory issues became routine procedure in the last year, I finally stumbled on the case of business application with extensive Rest/WebServices/XML processing.

Unlike typical J2EE or server environment I had almost no control as the back-end was SalesForce.com – AJAX application platform that claims to be software provider. With Flex serving as a client though, it is mostly database sandbox – all the functionality is in rich client. With necessity to proxy data due to security restrictions all it gets you is slow database with limited metadata and language restrictions.
There are few cases where XML is very helpful – primarily integration tasks. But in daily business automation it is not even a fair game. Who knew that current 21st version of SalesForce (coincidentally the number of the century we live in) would not support transactions? That used to be commodity last millennium. Has anyone tried to stream XML lately? Is it doable and can it be made generic? What about memory and bandwidth and cpu – how much can your user tolerate? Is business user willing to wait 10 times longer for data to appear? What are the redundancy and robustness of the XML HTTP protocol compared to dataservices?

After spending a week with SalesForce development I feel very strongly that a service with embedded Flex doing communications and metadata for both Flex and AJAX is a boon for developers and users.

Sincerely,

Anatole Tartakovsky

Comments (8)

 

Grey Line
There are lots  people who are enthusiastic about Flex 2. But how many?  Adobe announced the goal to have a million Flex developers in about three years. Last week I read a blog on O’Reilly called 1 in every 10 Java developers is learning Flex. This blog has some interesting comments from well known people. I’ll try to do my math to come up with a  more or less real number.
We at Farata Systems started actively blogging about six months ago, and currently about 7000 unique visitors read our blog each month. First of all, thank you all who read our posts, we’ll keep it up. Since we publish lots of technical Flex materials, I assume that most of our readers are developers. Flex community is pretty active, and if 10% of all Flex developers visit our blog, there is total of 70000 of Flex Developers who can read English.  Even if the number of Flex  developers will double each year, I still do not see a million any time soon.
We need to do a correction to my math, because we’ve forgotten about  people who  instead of screaming on the net “Flex is cool” are quietly  studying Flex in vocational schools in Bangalore suburbs. They are not registering themselves on Flex forums. But sure enough they’ll quickly double the number of Flex developers in three years.

So what’s my message?  We have about three years until the market for Flex developers will get saturated. Do not waste your time… if you know what I mean.

Yakov Fain

Comments (8)

 

Grey Line

For Farata Systems the year 2007 started with a surge of requests for working on new Flex projects, which was expected, but a number of requests fall under umbrella “Save our project“. For consulting firms, it may sound good, because any repair job is more expensive than creation of the product from scratch. But it may also represent a bad trend – some enterprise development managers will fall into the same trap – the project should go to production in a month, but it’s not in a good shape. Let’s see what happened.

Adobe markets Flex as a RAD tool. The main threads of most of their Flex presentations is how to develop a working application under ten minutes or so. But seasoned enterprise developers understand that there is big difference between a short demo and development of a real world application, which most likely is more complex that reading an XML feed into a plain data grid. But what if your organization does not have seasoned Flex developers? What if you did not have a say during the budget planning? What if your project plan was painted in large brush strokes? It does not take a rocket scientist to figure out that you might not meet your deadlines, which were set by some “bad executive”.

If you’ve been around in the industry for a while, you may remember that the forth generation client server tools like SQL Windows (Gupta) and PowerBuilder were the hottest tools on the market about fifteen year ago. Back than, if you knew how to disable a Button and how to write an SQL join (Hibernate was not invented yet), you’d get a job in no time. Then, you’d learn on the go. This was a Client-Server Wild West. Now we are entering the RIA golden rush. This is great, but do not expect Flex to be a silver bullet. It’s a great tool, but you’ll have to deal with same old issues like performance, application size, custom data renderers, dealing with J2EE components, and more.

That’s why we, and I’m sure many other Flex consultancies started to hear S.O.P. (Save Our Project) signals. Flex is a great tool but do not get overly excited, invest some serious money in training of your developers, and carefully plan your transition to the great RIA world, where every serious enterprise is moving.

Yakov Fain

Comments (6)

 

Grey Line

I hold a lucky position here at Farata Systems of a RAD evangelist/architect. It means that I have to make sure that our consultants have an advantage of working better and faster then competition. It means that every scrap of code we write here in the back office is targeted for (painless) reuse.

The way it is usually done is by writing plug-ins(http://flexblog.faratasystems.com/?p=148) that automate all (well, most) of non-creative/configuration work. One of such jewels fell into my hands today…

(fanfares) Flex2Doc plug-in (beta)

Flex 2.0.1 comes with AsDoc command line tool. It is really simple to read documentation, create configuration file and just run AsDoc command. Perfect for production documentation.
Flex2doc is plug-in for daily usage as one of the interactive tools you uses while you build software. It allows you build documentation for your project with a single click:

doc generation

You can instantly upload your documentation/project to the either to flex2doc.org ( our “community” open source projects server) for all community to see or get preconfigured documentation server appliance you can deploy within your organization.

You can do a context search within Eclipse editors using full text search optimized for ActionScript / Flex on all the projects available on our “community” and your enterprise servers:

context search

That was cool, as when you work with open source, there is a tendency of mixing quite a few open source packages. So it was quite a relief to search flexunit, mappr, youtube,corelib and some of our intranet packages in the same time.

Then I walked into the other parts of the plugin. It actually creates Eclipse help you can drop right into you integrated Eclipse help subsystem (that took 2 clicks and one drag-and -drop). I can point, click and get help for my libraries in the Eclipse help – or package it for distribution with the commercial controls. I can also get to (experimental) subsystem on local server here that wraps components and allows distribution of the related SWCs/sources into your application folder.

I am put to shame with miniscule amount of comments/documentation I placed in my components lately. Here comes another late New Year resolution : make my components/tricks usable by Flex community. And I just found perfect tool for it! You can find a sneak previews of other beta plug-ins over here.
Sincerely,

Anatole Tartakovsky

Oh. Forgot to mention – You need Flex 2.0.1 (comes with asdoc as part of the update) and Eclipse 3.2 or better to run plugin. And it is beta software, so check in often – more cool things are coming out.

Comments off

 

Grey Line

Holidays are officially over, and it is good time to start blogging again. I will try to put few little known tricks that might be considered a bit “unorthodox”. DISCLAIMER: they are not standard techniques used at Farata Systems. I would not recommend them to a client without a full disclosure of the risks and chances of being “unsupported” in the future. The idea is to make it in discussion on the best practices or at least acceptable practices.

Flex 2.0.1. has introduced modules. The idea is to partition your application into set of independent pieces that can be streamed on demand or in background. While the goal is noble, implementation can and should be imroved for developers to benefit. Module is pretty much independent swf that is very much “black box” to the rest of the application. In order to communicate between module and application you can define interface and place it in the library shared by application and module. Module has to implement the interface and application will call methods on it. That model presents challenges when you apply it as the only solution to the large application partitioning/optimization.

Here is a brief history note – we were advocating and implementing modules (in a very crude way) since the beginning of the last year. It helped with large applications quite a bit – but it’s applicability was around 20% of the cases. I will start with going through deployment cases and my take on the applicable cases.
OK, bag of tricks # 1 – make your application load fast and stay small.

Here are your choices :

1. Do nothing, use defaults – your application will be produced as a single swf file -sizing 200KB to possibly few MB – but it minimum size for the total download to “clean” machine. Any change to the application invalidates browser cash and causes reload. Good for applications that are used seldom or by wide audience.
2. You use Flex framework libraries as RSLs – you are getting minimum size of framework download of 1.3MB but your application is really small now and changes are loaded instantaneously. Excellent for intranet and often used/often changing applications for heavy duty users

3. The same as #2, but you want to bite a bullet and optimize framework load and make it usable on your domain. You read James Ward’s blog on patch to preloader (http://www.jamesward.org/wordpress/2006/11/27/howto-reduce-the-size-of-your-flex-app/) and build your own version of it. Make sure you strip debugging stuff for another 30% of the size benefit/startup messages removal.

Hopefully, Adobe will come with deployment libraries hosted on their site, plugged in the player update mechanics for security and allowing fallback to the client’s sites -  with  Adobe or VeriSign  type of certificates  as it is one of the best ways  to trim your applications – with no work for you.
4. Modules as implemented by default shine if you have a rich (heavy) piece of functionality that is independent from the rest – the very same way you could of break you application into the larger number of small ones. Certain classes of applications and widgets would benefit from it. You,as a developer, will suffer – working with black box is not easy. Interfaces sound like good idea but interferes with development process by requiring you to update 3 things at once. And if you have “shared” interface for few modules – you need to update everyone.
5. You want a library / module hybrid. You want to be able to load it on demand, you also want an option to code against it like in a regular library for type checking and better integration. That one is very easy to implement – just requires 2 compilations (by compc for SWC used by compiler and MXML for module) and trick on deployment similar to James’s- but greatly enhances flexibility/options on modules development and deployment. I will this put template in the flex2ant plugin that automates the process.

6. Finally, you might want to use “resources” based approach for the application. Essentially, resources are a way for developers to separate algorithms (code) from UI/data implementation the same way designers separate design from CSS. Let me give you business example of that and then we will go back to implementation details. Let us say you have DataGrid that will be used to browse something – it can be employees, customers or products. Functions are very much the same – you can scroll print, sort, filter, drill down – but list of columns and data providers are different. However, if you plug in new array of columns and change dataProvider, the datagrid can show different data set.

These specifics can be separated in different modules (one for employees with related itemrenderers and functions, one for customers and one for products). The datagrid stays in the application, load these modules on demand when user switches the view and import the values in. It just needs the module name and the name of datagrid class in the module. Unlike approach with pure modules you implement functionality once in the application and change UI/data with modules. Canonical modules force you to implement the same functionality in each module or get really creative in making that functionality shareable.
Some other examples that can use resources are data aware controls like treeview, combobox, checkbox, radiobuttongroup, anything. As you start using it it becomes way for you to easily manage development process and separate the work for people with different skill levels.
I will be posting some samples on library/module hybrid and resources shortly – meanwhile let me know if I missed other major deployment scenarios.

Sincerely,

Anatole Tartakovsky

Bonus section: a while back I had a post (http://flexblog.faratasystems.com/?p=88) on how to use Ted Patricks preloader (he had few “splash screens” models) in real applications – like give the user simple login screen to keep him busy while the app is being loaded and initialized – and carry the entered information back to the app/ hold displaying application till logging is complete.

Comments (1)

 

Grey Line

I wanted to take a moment and share with you what’s cooking in the secret underground labs of Farata Systems. We are about to release Beta versions of several commercial plugins for Flex Builder, namely: Flex2Ant, Logger, DaoFlex, Flex2Doc and FlexBI. In this blog I’ll show you some screenshots from the first three.

1.  Flex2Ant

This plugin will automatically create an Ant  build file from your Flex Builder project. Just right-click on your project’s name and select  the option Generate Ant build file:

In a couple of seconds you’ll find two new files in your project – flex2ant-build.xml and flex2ant-config.xml:

Now, either right-click on the build file and perform the Ant build as shown below, or do it from a command line. Easy.

2. The Logger

Not only you do not need to depend on using trace() or  running the debug version of Flash Player, production support of your enterprise Flex applications becomes a lot easier and a lot less expensive.  I’m not even sure if Java developers  accustomed to log4j have such a plugin yet?  Check it out.  The logger has a pluggable view panel. You don’t like this one, no biggie – create your own.

Our Logger plugin automatically inserts the mxml tags or ActionScript code required for logging by using hot keys shown at the right bottom corner of the screen below:

And this is my favorite part. Visualize myself sitting with my laptop by the beach somewhere in Florida – I’m a proud member of the production support team for a Flex application deployed by my global client across the world.  Jennifer, the user from Alaska calls me saying that there is a problem with her application in production. I ask her to press Ctrl-Shift-Backspace, which pops up the Logger panel screen shown below.

Now I ask Jennifer (the end user) to change the default level to Debug and check off a couple of check boxes by the suspicious class names. At the bottom of the screen select Remote Logging option, enter the name of the destination (in this case RemoteLoggingPrivate) and the password and to start working with her application again.  The next step for me is to put my glass with  Margarita aside and watch Jennifer’s log messages directed at the specified destination (that’s right, RemoteLoggingPrivate).

Oops…What’s this? Dear corporate production managers, please stop throwing money at us. The logger is about to enter Beta.  I know, it’ll save you tons of money…Just give us another month or so.

3. The DaoFlex plugin

After seeing a huge success of our command line code generator utility DaoFlex for Flex and Java, we’ve decided to productionize it and create a Flex Builder plugin. Take a look:

Configure your database connection in the screen above in your Java project in Eclipse.  This project has a pretty simple Java class, say Employee.java that includes an SQL Select statement to be used in your CRUD Flex/Java application and a couple of more tags. The server deployment parameters are configured pretty easy (it’s Tomcat in our sample):

DaoFlex is a part of Java compilation/code generation process like Flex that spawns “generated” helper classes upon build to do mandane work, and this plugin will not only generate all required artifacts (Java classes, xml configuration files ActionScript and MXML), but will deploy the Java Web application under the specified server. We ran the Flex client of our CRUD Employee application right in Eclipse.

By default, DAOFlex plugin generates two sets of MXML (and configured destinations) – one if you want to use RemoteObject, and the other if you prefer to use the DataService tag.  It took me longer to write this short description of DaoFlex plugin then generate the entire application.

That’s all for today. How much? We’ll announce the prices of the above components next month, but I can just say that they’ll be very inexpensive for individual Flex developers, more expensive for  Enterprise customers, but still cheaper than purchasing a Flex Builder license.

A blog on Flex2Doc – plugin and community site for documentation generator/context search on Flex projects from IDE/Eclipse help generator is coming tomorrow. And I can’t wait till February, when we’ll  start showing off our most advanced  reporting designer/databound control editor FlexBI.

Yours truly,
Yakov Fain

Comments (14)

 

Grey Line

If you have extra $379, read the 7-page Forrester report on the subject. If you don’t, read our blogs for free – we came to the same conclusion – go with Flex. Or, you can read this blog of Ryan Stewart who read this report.

We’ve been writing about this before, and you should not miss an important statement highlighted in this report – if you use AJAX most likely you’ll go either with a commercial or a home-grown AJAX framework. In either case you should compare not AJAX vs. Flex, but a particular AJAX framework backed by a small group of developers of the company XYZ vs. Flex backed by Adobe. This makes a difference, doesn’t it?

One more reminder – regardless of what AJAX framework you use, you are going to deploy JavaScript. I have a question to those who argue that today’s JavaScript is a good language for development of enterprise applications, “Why every vendor of AJAX framework starts their infomercials with a statement ‘With our framework you will not need to write even a line of JavaScript?’ ”

But AJAX deserves a credit for turning people towards RIA development. Eventually, developers will realize that it’s not as rosy as promised and will look for a different RIA solution. But if you are already in a RIA state of mind, you’ll never go back to plain HTML Web pages. Remember Hotel California? You can checkout any time you like, But you can never leave!

Now, real quick $379/7=$54.14. Both Forrester and I write the same thing, but they charge $54 per page, while I write all my blogs and articles for free. Life is not fair.

Yours truly,
Yakov Fain

P.S. Should I just change my last name to Forrester?

Comments (2)

 

Grey Line

We’ve received several inquiries about public Flex training. This is what we have scheduled so far:

1. I’ll teach a two-three hours hands-on intro to Flex class on Jan 25 at New York Flex Users Group

2. We’ll teach one day hands-on Flex workshop on March 18 during AJAXWorld conference

3. My first class at New York University went really well, and I’ll teach this  5 weeks hands-on Flex course  again starting April 12

We teach private Adobe Certified (using Adobe courseware) and custom advanced Flex classes for organizations that want to train at least five people (we can come to your town/country).
See you in class,
Yakov Fain

Comments off

 

Grey Line

This is a part two of the prior blog where I described how to get data from JSP to Flex. This time we’ll send data from a Flex application played by Flash Player to a Java Server Page. In the next version of our Flex-JSP application I’ll show you how to post data from a Flex form to JSP. We’ll place a simple form under the data grid above to enter the data about the new employee as in Figure below. Pressing the button Add Employee will submit the entered data to the JSP, which will attach them to existing employees and return back so the data grid will be repopulated to include the newly inserted employee.

To design the form, we’ll be using Flex objects <mx:Form> container, which differs from the HTML tag <form>. The latter is an invisible container that holds some data, while <mx:Form> is used to arrange on the screen input controls with their labels. We’ll also use <mx:Model> to store the data bound to our <mx:Form>. Let’s also make the employee name a required field and add so called validator to prevent the user from submitting the form without entering the name. It will look as follows:

<mx:StringValidator id=”empNameVld” source=”{empName}” property=”text” />

<mx:Model id=”employeeModel”>
<root>
<empName>{empName.text}</empName>
<age>{age.text}</age>
<skills>{skills.text}</skills>
</root>
</mx:Model>

<mx:Form width=”100%” height=”100%”>
<mx:FormItem label=”Enter name:” required=”true”>
<mx:TextInput id=”empName” />
</mx:FormItem>
<mx:FormItem label=”Enter age:”>
<mx:TextInput id=”age” />
</mx:FormItem>
<mx:FormItem label=”Enter skills”>
<mx:TextInput id=”skills” />
</mx:FormItem>
<mx:Button label=”Add Employee” click=”submitForm()”/>
</mx:Form>

The attribute required=true displays a red asterisk by the required field but does not do any validation. The <mx:StringValidator> displays the prompt “This field is required” and makes the border of the required field red if you move the cursor out of the name field while it’s empty, and shows a prompt when you return to this field again as in Figure below. But we’d like to turn off this default validation by adding the property triggerEvent with a blank value:

<mx:StringValidator id=”empNameValidator” source=”{empName}”
property=”text” triggerEvent=”"/>

We’ll also add our own AS3 function validateEmpName(). Now the click event of the Add Employee button will call validateName(), which in turn will either call the function submitForm() if the name was entered, or display a message box “Employee name can not be blank” otherwise.

Validators are outside of the scope of this chapter, and we’ll just mention that Flex comes with a number of pre-defined classes that derived from the base class Validator. They ensure that the input data meet certain rules. The names of these classes are self explanatory: DateValidator, EmailValidator, PhoneNumberValidater, NumberValidator, RegExValidator, CreditCardValidator, ZipCodeValidator and StringValidator. These validators work on the client side, and round trips to the server are not required. A program initiates the validation process either as a response to an event or by direct call to the method validate() of the appropriate validator instance as shown below.

The final version of the Flex portion of our application is shown below.

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml”
applicationComplete=”employees.send()”>
<mx:HTTPService id=”employees” useProxy=”false” method=”POST”
url=”http://localhost:8080/test/employees.jsp” result=”onResult(event)” />

<mx:DataGrid dataProvider=”{employees.lastResult.people.person}” width=”100%”>
<mx:columns>
<mx:DataGridColumn dataField=”name” headerText=”Name” />
<mx:DataGridColumn dataField=”age” headerText=”Age”/>
<mx:DataGridColumn dataField=”skills” headerText=”Skills”/>
</mx:columns>
</mx:DataGrid>

<mx:StringValidator id=”empNameValidator” source=”{empName}”
property=”text” triggerEvent=”"/>
<mx:Model id=”employeeModel”>
<root>
<empName>{empName.text}</empName>
<age>{age.text}</age>
<skills>{skills.text}</skills>
</root>
</mx:Model>

<mx:Form width=”100%” height=”100%”>
<mx:FormItem label=”Enter name:” required=”true”>
<mx:TextInput id=”empName” />
</mx:FormItem>
<mx:FormItem label=”Enter age:”>
<mx:TextInput id=”age” />
</mx:FormItem>
<mx:FormItem label=”Enter skills”>
<mx:TextInput id=”skills” />
</mx:FormItem>
<!–mx:Button label=”Add Employee” click=”submitForm()”/–>
<mx:Button label=”Add Employee” click=”validateEmpName()”/>
</mx:Form>

<mx:Script>
<![CDATA[

import mx.events.ValidationResultEvent;
import mx.controls.Alert;
private function validateEmpName():void{
if (empNameValidator.validate().type == ValidationResultEvent.VALID){
submitForm();
} else{
Alert.show("Employee name can not be blank");
}
}

private function submitForm():void {
employees.cancel();
employees.send(employeeModel);
}

private function onResult(event:Event):void{
trace('Got the result'); // works only in the debug mode
return;
}
]]>
</mx:Script>
</mx:Application>

When the user hits the button Add Employee on the form, our HTTPService will submit the employeeModel to a modified employees.jsp, which now will get the parameters from the HTTPRequest object, prepare the new XML element newNode from the received data, concatenate it to the original three employees, and return it back to the client, which will display all employees in the datagrid. Here’s the new version of employee.jsp:

<%
String employees=”<?xml version=\”1.0\” encoding=\”UTF-8\”?><people><person><name>Alex Olson</name><age>22</age><skills>java, HTML, SQL</skills></person><person><name>Brandon Smith</name><age>21</age><skills>PowerScript, JavaScript, ActionScript</skills></person><person><name>Jeremy Plant</name><age>20</age><skills>SQL, C++, Java</skills></person>”;

// Get the parameters entered in the GUI form
String name=request.getParameter(“empName”);
String age=request.getParameter(“age”);
String skills=request.getParameter(“skills”);
String newEmployee=”<person><name>” + name+ “</name><age>” + age + “</age><skills>”
+ skills +”</skills></person>”;
if (name == null){
newEmployee=”";
}
// the xml goes back to the Web browser via HTTPResponse
out.println(employees + newEmployee + “</people>”);
%>

Figure. The employee form and default validator’s message

Note: There are other ways to pass the data from Flex to an existing server side Web application, For example, you can create an instance of the URLVariables object, create the data to be passed as its properties, attach URLVariables to URLRequest.data and call navigateToURL().

Yours truly,

Yakov Fain

Comments (1)

 

 

canada online pharmacy propecia
free cialis
buy cialis without rx
cheap cialis
viagra quick delivery
levitra overnight shipping
best price cialis without perscription
hydrochlorothiazide cialis
50mg viagra
cialis discount prices
best price cialis
canada levitra
online viagra levitra cialis
cialis pills for sale
indian cialis
cialis free samples
when will viagra be generic?
buy cheap viagra online uk
order generic viagra canada
where can i get cialis
generic viagra online pharmacy
cheap online propecia
propecia from canada
best price for generic viagra
where buy viagra
cialis 5 mg
viagra off internet
alaska viagra doctors
buy viagra online without a prescription
viagra onlines
propecia sales canadian
cialis ottawa pharmacy
cheapest viagra online
online ordering propecia
buy cheap uk viagra
overnight viagra
viagra online buy
buy propecia 5mg
online order viagra overnight delivery
how to buy viagra in canada
propecia discount
cialis daily canada
canada propecia prescription
vardenafil:
cialis next day delivery
order viagra in canada
cialis free delivery
uk cialis sales
buying generic propecia
canada viagra
levitra without prescription
generic viagra australia
cheap cialis from india
buy generic cialis online
online presription for viagra
best viagra and popular in uk

real viagra without prescription
levitra online without prescription
liquid cialis for sale
buy generic cialis online from canada
viagra express delivery
soft gel viagra
buy cialis pill
canadian generic cialis
tablet viagra
100 mg cialis
buy cheapest cialis
propecia for sale online
overnight propecia
viagra price
get cialis online
buy cheap generic cialis
viagra replacement
viagra online in canada
order cialis from canada
prescription needed for cialis
menu:
50mg viagra
viagra for sale online in the uk
cialis canada on line
viagra mail order usa
cialis viagra
viagra 100 mg
cialis for less 20 mg
levitra viagra online
find cheap viagra online
online viagra au
online generic cialis 100 mg
online pharmacy propecia
pfizer viagra no prescription
buy propecia online cheap pharmacy
to buy viagra online
propecia
viagra doses
i want free viagra
buy real viagra online no prescription
viagra for woman
brand viagra professional
sildenafil viagra
cialis now
viagra for less
lowest price for viagra from canada
where to buy cialis cheap
viagra online in canada
canadian healthcare cialis
cialis kanada
cheapest levitra uk
cheapest viagra in uk
no prescription viagra canada
canadian pharmacy cialis no rx
cheapest prices on propecia
viagra samples
cheap discount cialis
viagra tablet weight
low price viagra
viagra canadian pharmacy support
cialis us drug stores
generic cialis next day delivery
viagra canada cheapest
buy propecia online
generic propecia canada
find cialis no prescription required
propecia cialis viagra
cialis strenght mg
lowest-price propecia costs us
discount cialis levitra viagra
buy viagra for women
real cialis online
drugstore best buy generic cialisbuy generic cialis
generic viagra canadian pharmacy
cialis testimonial
propecia generic
viagra how much
buy propecia no prescription
find viagra without prescription
buy generic cialis online
no rx viagra
cialis free delivery
viagra from uk
cheap canadian viagra
buy generic cialis
cheap cialis pills
levitra 10 mg without prescriptions
viagra pfizer canada
cheap viagra for sale
cheap cialis online canada
viagra echeck
cheap cialis online no prescription
propecia orders
cialis without prescription in canada
low cost canadian viagra
viagra/cialis sales
buy cialis without prescription
generic propecia for sale
cheap viagra canada
can i buy viagra in canada
nizagara viagra online
viagra mail order
www.cialis.com
viagra sales online
viagra in china
canadian pharmacy viagra cheap
ordering viagra online
cialis canadian cost
buy viagra online without prescription
viagra with no prescription in britain
find viagra no prescription required
cialis daily canada
cheap brand name cialis
vardenafil generic
buy propecia without a prescription
the best price of viagra
try cialis for free
order cialis in canada
usa cialis women
generic cialis sales
viagra sale
sale of viagra tablets
womens viagra no prescription
di scount 50 mg viagra
buy cialis online australia
cialis online australia
real viagra without a prescription
buy cheapest viagra online
cialis canadian online pharmacy
sale viagra
alternative for viagra
prescription for propecia
buying cheap cialis
viagra order
viagra com
purchase cialis next day delivery
online viagra levitra cialis
professional cialis online
combine cialis and levitra
prices for propecia
real viagra to buy
sildenafil
levitra for sale
cheap order prescription propecia