Archive for August, 2011

alaint

Android SDK Install: Java SE Development Kit (JDK) not found.

Tuesday, August 30th, 2011

By Alain Thibodeau – Consultant

If you are installing the exe version of the Android SDK you might get a warning message. This message is warning you about not being able to find the JDK. You’ll end up double checking your JDK setup for nothing and wasting time.  I’ve seen this happen on Windows XP and Windows 7.

Below is a screen cap of the error you will see:

 

If you do get this message, just hit the back button and then next button, et voilà

Derek Santos

Object Oriented JavaScript – Part 1

Monday, August 29th, 2011

By Derek Santos – Consultant

Go to Part 2
Go to Part 3

Back about 5-6 years ago in my PHP days, I was doing a lot of JavaScript.  It seems more and more that JavaScript will be a major player in the future with HTML5.  With that said, it’s important to think about how HTML5 applications will be architected and organized.

There’s a common misconception that JavaScript is not object oriented.  While OO principles may not be the foundation of JavaScript, it is possible to implement OO principles in JavaScript.

Prototypal vs. Class-based

JavaScript is a prototypal language.  What this means is that object behavior may be cloned based on other objects (or prototypes).  In traditional class-based languages, object relationships and behavior are typically defined at compile-time.  In a prototypal environment, they are defined at runtime.  This is why every object in JavaScript has a prototype property.

Defining a Class/Prototype with JavaScript

Here are two ways you can define a class with JavaScript.

Method 1: Within Constructor

This method is really simple and common.

function Person() {
    this.firstName = "Derek";
    this.lastName = "Santos";
}

var person = new Person();

Method 2: Using prototype

This method allows you to modify a class definition outside of its constructor.

function Person() { }
Person.prototype.firstName = "Derek";
Person.prototype.lastName = "Santos";

var person = new Person();

Declaring Class methods

To declare a method in a class, you can simply define it within the classes constructor like so.

function Person() {
    this.firstName = "Derek";
    this.lastName = "Santos";
    this.showName = function() {
        alert(this.firstName + " " + this.lastName);
    }
}

var person = new Person();
person.showName();

This is just the tip of the iceberg, many other OO concepts can be implemented in JavaScript.  Keep an eye out for Part 2 of this article where I’ll talk about inheritance and other OO principles.

cathyj

Creating a DropDown List for PlayBook Applications

Monday, August 29th, 2011

By Cathy Jin – Consultant

If you’re using Flex 4.5.1 to develop a PlayBook application, you will notice that there is no DropDown list control in the Component View. This is due to the fact that DropDown list is not mobile optimized for Flex. I’ve tried to use it but had little success. There are two possible solutions:

1. You can use a Text Input box and a list popup window. You can refer to this link for an example: http://www.adobe.com/devnet/flex/samples/expense-tracker-application.html.

2. An alternative is to use a QNX component, but you will need to rewrite the code if you want the application to run on different operating systems such as iOS or Android. You can find more infromation on using QNX components at the link: http://corlan.org/2011/02/01/working-with-playbook-qnx-list-components/.

Good luck!

seanh

Looking Into the Strengths of JavaScript

Friday, August 26th, 2011

By Sean Hopen – Consultant

I’ve been digging deeper into JavaScript a bit lately, because it’s becoming a big player out there. HTML5’s new capabilities have the rich internet development world looking at what can be done with it, and JavaScript is what you need to really make it work. People are even using JavaScript for server-side development with node.js.

I never took JavaScript very seriously. The syntax seemed a little flakey, it wasn’t really object oriented, it wasn’t strongly typed, and it was hard to debug.  I missed out on some of the strengths of the language. I may not have, had I known that JavaScript was influenced heavily by Lisp, a language I loved when I was doing AI programming.

I’d say the key factor in my appreciation of JavaScript is the functional programming style, including the use of closures. These are all new things, or partly new, for folks that are steeped in the C tradition (including visual basic, C++, java, etc.). There are also new tools to work around the syntactic problems with JavaScript (the language was designed in 10 days!). Check out tools like JSLint.

Note: You can find out more about this, and other good stuff about JavaScript from Doug Crockford’s highly recommended talk. I also recommend Alex Russell’s talk too.

So why do we like Functional Programming and closures? These are topics for another blog post each, but in short:

Functional programming is cool for at least two reasons:

1) There is a resurgence of interest in FP because it’s easier to adapt to concurrent programming on multiple processors and for asynchronous communication.

2) Its a style of coding that can be incredibly expressive with very few keystrokes.

Closures, also two reasons:

1) In JavaScript it’s essential to scoping variables. Having nothing but globals is hideous to software engineers and death to apps of any size at all.

2) Same point as above. Its part of the powerful expression you can get with functional programming. You just have to get used to passing around functions instead of objects. Closures allow you to encapsulate data in those functions.

I’ve started playing around with a really good example of the power of functional programming; something called Reactive Extensions (Rx).  I’ve been obsessed for years with finding a better way to write code that handles asynchronous operations (as we do every day on the web) in a way that the code captures the intention of the design (which we don’t see every day). Functional programming completely changes the way I think about asynchronous operations.  I’m going to play around with this a bit before writing a blog about this. If you’re already convinced, Google Reactive Extensions for JavaScript. There’s a also good introduction here, and a video by the guy that invented it here.

I’d would love to hear your thoughts on what I’ve written.

oliverm

Adobe's Flex Future

Friday, August 26th, 2011

By Oliver Merk – Principal Consultant

Despite the rumors, Adobe hasn’t quite thrown up their hands and accepted the HTML5 future envisioned by so many. In the following article, Andrew Shorten lauds the Flex Mobile framework and rails against the Flash FUD that Adobe always takes seriously.

Looks like Adobe could use more developers in its Flex corner. Maybe a Flash Builder for Linux after all, Andrew?

http://blogs.adobe.com/flex/2011/08/flex-where-were-headed.html

What do you think – is Flash doomed? Is HTML5 going to rule the world? Please leave a comment below.

andreiv

Actionscript: Using Weak References to Avoid Memory Leaks

Friday, August 12th, 2011

By Andrei Vanahel – Consultant

As most of us know, negligent usage of Event Listeners causes memory leaks.  Let’s use Timer as a good example.

The way we usually declare Timer objects looks similar to this:

var timer:Timer = new Timer();

timer.addEventListener(TimerEvent.Timer, timerEventHandler)

What happens here is that timerEventHandler becomes a reference to an object, and this object would never be garbage collected until Timer object is destroyed or Event Listener is removed.

The most common way to remove Event Listeners is to call the removeEventListener function:

timer.removeEventListener(TimerEvent.Timer, timerEventHandler).

But in many cases I have seen developers simply ignore or forget to clean Event Listeners, and in rare cases developers put removeEventListeners in the wrong place which causes other issues. Here is an alternative: weak references. Wikipedia defines a weak reference as “reference that does not protect the referenced object from collection by a garbage collector”.  In other words an object that has only weak references will be marked for deletion and is eligible to be garbage collected.

In order to mark references as weak we just need to set the fifth parameter of addEventListener function to true:

timer.addEventListener(TimerEvent.Timer, timerEventHandler

1
,false,0,true);

As usual, each method (removeEventLister function or weak references) has advantages and disadvantages, so it up to you to decide which one is more suitable in your situation.

Rod Nolan

Configuring ColdFusion 9.01 with IIS 7 to use a Network Share as the Webroot

Thursday, August 11th, 2011

By Rod Nolan – Consultant and Senior Instructor

Recently I was tasked with installing and configuring ColdFusion 9 in the multi-server configuration. I wanted to segregate some applications that were suffering from poor performance and occasional out of memory crashes so the idea was to to create a handful of ColdFusion instances so that the “bad” apps could crash and burn all by themselves.

So here are the basics of the server environment:

  • Windows Server 2008 (virtual)
  • IIS 7
  • ColdFusion 9.01 Enterprise
  • IIS and CF installed on the same VM
  • webroot folder is on a file server accessible via UNC path

I won’t get into the low level details of how to do this configuration but at a high level the requirements are as follows:

  • create a domain account under which the ColdFusion service will run
  • create web sites in IIS and configure the doc root to point to the UNC share
  • configure the UNC share to log in using the ColdFusion service account credentials
  • create ColdFusion instances and bind them to the IIS web sites

After running through these steps, IIS was able to serve static pages without issue. But any request for a ColdFusion page resulted in a file not found error (coldfusion.runtime.TemplateNotFoundException: File not found: /index.cfm). The files I was requesting were certainly, absolutely, without a doubt, positively present in the folder where they should have been! I should also note that the very same UNC share was configured as the doc root for a ColdFusion 8 server on Windows Server 2003 with IIS 6. So what could be wrong here?

To eliminate any possible permissions issues, I granted the service account Full Control rights to the appropriate folders within the UNC share. But, in the end, this wasn’t enough. To finally resolve this error, I had to grant the ColdFusion service account remote logon rights for the Windows Server 2008 VM (something you normally wouldn’t do), log on as that user, navigate to the UNC share and then delete and recreate my doc root folders. The CF service account needed to be the owner of the doc root folder in this situation. Full Control wasn’t enough!

I’m not an experienced Windows Server administrator by any means. If you are, maybe this would be obvious to you. But I thought that Full Control is as good as it gets. I learned later (from a full time Windows Server admin) that I may have been able to avoid the delete folders/recreate folders routine by transferring ownership of the folders from the original creator to the ColdFusion service account. I thought it’d be best to NOT mess with a working configuration so I never tested this theory.

I was lucky to have access to Adobe Platinum Support on this one and thanks are due to the two support engineers who worked with me over the course of a couple of days to finally get to the bottom of the issue.

oliverm

A Date with SQLite

Thursday, August 11th, 2011

By Oliver Merk – Principal Consultant

Been doing a lot with SQLite lately (sqlite.org) on the PlayBook and elsewhere and wanted to pass on a few quick notes.

First, SQLite columns are typeless.

What?

Yup. Even though you may declare fields as VARCHAR or DATETIME, you may actually store any type of data you want in them. The exception to this rule is for PRIMARY KEY fields declared as INTEGER.

I’ve found that typeless fields can lead to some problems when storing and retrieving date values. I suspect that minor version differences in SQLite are returning different CURRENT_TIMESTAMP values.

Here’s an example of some SQL which creates a table with a date field:

CREATE TABLE location (
    location_ID INTEGER PRIMARY KEY NOT NULL,
    name VARCHAR,
    latitude NUMERIC NOT NULL,
    longitude NUMERIC NOT NULL,
    addDate DATETIME DEFAULT CURRENT_TIMESTAMP);

If I INSERT a new record without specifying the addDate value, SQLite will default to inserting its CURRENT_TIMESTAMP value to populate the addDate field and I get something like 2011-08-11 12:05:10.

But if I decide to explicitly use CURRENT_TIMESTAMP in my insert statement, the value gets stored in an odd-looking decimal format. For example, 2455769.105023148.

Depending on the SQLite version, I may or may not be able to convert the returned date field using JavaScript’s date parsing functions for fields inserted with CURRENT_TIMESTAMP:

Client SQLite version Format Supports JS Date parsing
Chrome (Win) 13.0 beta 3.7.6.3 NO
Firefox (Win) 5.0 3.7.5 NO
PlayBook AIR Runtime 3.7.3 YES

My concern is that the code which now works with the PlayBook might break when it gets its next SQLite update. Guess I’ll burn that bridge when I get to it.

I should also mention a great Firefox add-on called SQLite Manager that allows you to manage these databases.

Oh, and how did I get the SQLite version?

SELECT DISTINCT sqlite_version() AS version FROM sqlite_master;

I’ll leave the rest up to you…

Chad Upton

Adobe Edge: Flash Like Animation with HTML5 CSS and JavaScript

Wednesday, August 10th, 2011

By Chad Upton – Senior Consultant

Flash started out as an animation platform, but quickly became a tool for building Rich Internet Applications. It’s a very powerful runtime that exists on many platforms, but it’s not on all of them. One of the few environments that is more ubiquitous than Flash, is the web browser. Unfortunately, the tools for developing content in HTML, CSS and JavaScript are still very elementary compared to the tools we have for desktop applications.

Adobe makes Dreamweaver, one of the most popular web development tools, but it is not as comprehensive as Flash for building applications. One area where Dreamweaver falls short is animation. Enter Adobe Edge.

Adobe Edge is currently in preview; it’s not finished yet. So far it’s a very nice animation platform that renders content using HTML5, CSS and Javascript — no Flash Player required.

The animation capabilities are very similar to Flash; however, the user interface is less like Flash and more like Adobe’s video editing applications like Premiere and After Effects. UI aside, the concept is very similar to Flash and Flash users will pick it up quickly. Just like Flash, the results can be very impressive. In fact, I tested some of the following samples on mobile devices and the performance was excellent too.

Samples that were created with Adobe Edge:

If you want to see the product in action, have a look at the getting started video.

Thanks for reading, and if you want to learn more about HTML5, CSS and JavaScript, join us online or in person for an HTML5 course!

Adobe Edge Links:

alaint

Generate a Certificate with ADT and ANT

Wednesday, August 10th, 2011

By Alain Thibodeau – Consultant

AIR and mobile applications need to be signed. Most of the time we use the same self-signed certificate to package our applications. There are times when you may want to use a different self-signed certificate or create one on the fly. This is possible using ADT and ANT.

Adobe’s documentation states the ADT certificate command use like this:

adt -certificate -cn name -ou orgUnit -o orgName -c country -validityPeriod years key-type output password

To incorporate with ANT we would do something like this:

Properties file:

cert.keystore=mycertificate.p12
cert.name=SelfSignedCertificate
cert.orgunit=Software Development
cert.orgname=newyyz
cert.country=CA
cert.keytype=2048-RSA
cert.password=mypassword

Build file:

<target name=”generate.certificate”>
<exec executable=”${ADT}”>
<arg value=”-certificate” />
<arg value=”-cn” />
<arg value=”${cert.name}” />
<arg value=”-ou” />
<arg value=”${cert.orgunit}” />
<arg value=”-o” />
<arg value=”${cert.orgname}” />
<arg value=”-c” />
<arg value=”${cert.country}” />
<arg value=”${cert.keytype}” />
<arg value=”${cert.keystore}” />
<arg value=”${cert.password}” />
</exec>
</target>

You can find more information here: http://help.adobe.com/en_US/air/build/WS901d38e593cd1bac1e63e3d128fc240122-7ffc.html