Archive for August, 2006

* JavaStudio Creator Webinar Online

Posted on August 28th, 2006 by Dave Johnson. Filed under AJAX, Declarative Programming, JSF, NetBeans.


A few weeks ago we did a short webinar with Sun to show off our Ajax Grid component in JavaStudio Creator (JSC). It lets a developer use all the nice visual aspects of JSC with the power of Ajax!


Check it out.

.



* Nitobi Podcast #11

Posted on August 17th, 2006 by Dave Johnson. Filed under AJAX, Podcast.


Podcast 11 is up! We talked about a few random things as usual with one or two digressions. Mostly we talked about open source and our Ajax framework. Although I wanted to talk about the latest happenings in Lebanon I tried to stick to the script ;)
Happy listening and as usual feel free to comment here or just email me at dave(youknowwhatgoeshere)nitobi.com.

Pick up the feed or just listen here:

MP3 File

.



* Extending an Ajax Component

Posted on August 14th, 2006 by Dave Johnson. Filed under AJAX, Components, JavaScript.


Ajax components are not only cool but actually quite useful - and I am not just saying that as a component vendor but as a web application developer. At nitobi we do both consulting and component development and when doing consulting we shy away from actually changing the component source code to do things that we need and instead focus on extending core components.

Since JavaScript is a dynamic language, one can really easily extend functionality. Most notably, many will have at least heard of aspect oriented programming which is the idea of adding before, after, or around advice - which just means running some code before, after or around some predefined method.

Let’s take a look at a quick example. As many already know, classes in JavaScript are defined as functions.

// Define the Dog class
function Dog()
{
    this.breed = ‘berner’;
}
// Define the speak method on the Dog class
Dog.prototype.speak = function()
{
    alert(’w00f’);
}

That defines a Dog class that has a public property for the dog breed and a public method to make that pooch sing.

So let’s pretend that I am an Ajax component vendor (who knew) and to make my JavaScript load faster I might go ahead and remove the white-space, remove comments, and even replace long variable names with shorter ones. This all happens when I “compile” my JavaScript on my server before I let people access it.

If this were a compiled DLL say, then it would be more problematic to do something like change what the dog says based on the breed of the dog - particularly if this has to be done at runtime rather than compile time. Luckily for us AJAX developers, JavaScript is very flexible :)

The first thing that we can do is create a new instance of our Dog class and actually replace the speak method with something completely different.

// Create a new instance of a Dog
var berner = new Dog();
// Re-define the speak method for this instance only
berner.speak = function() {
  alert(’I am a Bernese Mountain Dog’);
}

If we wanted to change every new instance of the Dog class we can also change the actual class definition by changing the prototype property just as the original author did.

// Re-define the speak method for the class
Dog.prototype.speak = function()
{
  alert(’I am a ‘ + this.breed);
}

Alternatively, we can also add code that will run before or after the speak function. We can define a static function called attachAfter in the aspect namespace that will take an object to which some method belongs (sourceContext), a string that is the name of a method on that object (sourceMethod), and a reference to function object that we want to call after the source method is called (aspectMethod). aspect.attachAfter is pretty simple and looks something like this:

aspect.attachAfter = function(sourceContext, sourceMethod, aspectMethod)
{
    var oldMethod = sourceContext[sourceMethod];
    sourceContext[sourceMethod] = function()
    {
        oldMethod.apply(sourceContext, arguments);
        aspectMethod.apply(sourceContext, arguments);
    }
}

We use the JavaScript apply method here such that we can pass the arguments list that the method is to be called with. To actually use this with our Dog class we could either augment the instance of the class or even the class itself. Here is an example of attaching some function that will alert the breed property of the dog after the dog speaks.

var berner = new Dog();
// This will just alert ‘w00f’ as we expect
berner.speak();
// Now attach an after function to the speak method
aspect.attachAfter(berner, “speak”, function(){alert(’I am a ‘+this.breed)});
// This will now alert ‘w00f’ and then ‘berner’
berner.speak();

Notice that we can even execute the after function in the context of the berner object and therefore we have access to the this keyword in our attached function.

I am going to look at more JavaScript features in the coming weeks including inheritance and dynamic XML parsing. If anyone sees any problems here let me know!

Technorati Tags: ajax, components, javascript, patterns, architecture

.



* Snakes on a Plane

Posted on August 11th, 2006 by Dave Johnson. Filed under Business, Fun.


For those that have not had Samuel L. call them from the Snakes on a Plane website then get on it!

http://snakesonaplane.varitalk.com/

This has to be the best viral marketing campaign I have heard (pun intended) in a long time.

Technorati Tags: marketing, snakesonaplane, business

.



* Nitobi Podcasting Session 10

Posted on August 9th, 2006 by Dave Johnson. Filed under AJAX, Patterns, Podcast.


From Andre’s blog…

Dave and I discuss JavaScript programming techniques and patterns such as inheritance, multiple inheritance, observer patterns and more. We also touch on the nonesense around Ajax security risks. Mentions also of BarCamp Vancouver and we're hiring at Nitobi! Until next week on the same bat channel at the same bat time:)

MP3 File

Technorati Tags: podcast, ajax, javascript, patterns, barcampvancouver, hiring

.



* Nitobi Grid and Google Maps Mash’d-up

Posted on August 2nd, 2006 by Dave Johnson. Filed under AJAX, Components, Google, Map, Web2.0.


I have been meaning to do some mashup action for a long time now and finally found some time. Andre tried to steal my screenshot cause I originally made it for his talk at GeoWeb. I have just made a screencast of it to give people an idea of how it all works.

The idea was to use our Ajax Grid control to provide a nice interface into which addresses could be entered and then plotted on a Google Map.

So what this enables people to do is copy addresses from MS Word, Excel or even OpenOffice products - no proprietary tricks here. Of course the Grid currently only works in FF and IE (sorry safari users). Then when I click on the “plot addresses” button (which could also happen every time I edit a record in the Grid for example) a request is made to the Google server for each record in the Grid and it does the geocoding - ie converting an address to lat/long - which can then be plotted on the map. It is a pretty sweet thing to be able to take a bunch of addresses and get them plotted on am online map!

Here is the screencast (sorry about the crappy audio :)) and I will try and get the sample up in the next few days so that people can actually try it out!

Technorati Tags: google, ajax, map, web2.0

.



* Enterprise AJAX Podcast #9

Posted on August 2nd, 2006 by Dave Johnson. Filed under AJAX, Patterns, Podcast, Web2.0.


Andre and I discussed the new Nitobi name and brand, WebVisions 2006, Ajax Patterns with Michael Mahemoff, Geoweb with Ajax and GIS, Ajaxworld and the 3 pillars of Ajax.


MP3 File

.