Categories
Dev

Simple JSON-RPC Class

JSON-RPC is a simple methode to transfer data without site refreshing from the server to the client. It’s an alternative to AJAX calls and used in many web applications, for example most of the google apps use it for their client-server communication. Here’s my simple implementation:

The Class

jsonRPC = function() {
   cbstore = new Object();
   var counter = 0;
   var base = "insert your base url here";
   var encode = encodeURIComponent;

   var cleanup = function(id, s) {
      delete this.cbstore[id];
      setTimeout(function() {
         document.body.removeChild(s);
      }, 0);
   }
   this.send = function(params, callback) {
      var id = "cb" + ++counter;
      var timeout = setTimeout(function() {
         cleanup(id, s);
         callback(null);
      }, 2000);
      cbstore[id] = function(data) {
         //cancelTimeout(timeout);
         cleanup(id, s);
         callback(data);
      };
      var s = document.createElement("script");
      document.body.appendChild(s);
      s.src = base + "?callback=cbstore." + id +
      "&" + (params);
   }
   this.call = function(params, callback) {
      this.send(params, function(data) {
         if (!data || data.Status.code != "200") {
            callback(null);
         } else {
            var c = data.pois;
            callback(c);
         }
      });
   }
}

The Serverside

To trigger the clientside callback function you must insert it in your server-side response. The response must look like this:

print (insert the callback function process from GET here + "({Status: { code: 200, request: \"getpois\" }, pois: [");


//output of your data in JSON format

print("]})");

Usage

mycall = new jsonRPC();
mycall.call("insert some params here", function(json) {
	if (!json || json == undefined || json == null)
		return;

       //do something with the response data here



});

What’s next

To be honest, this is a very ugly implmentation and I have to work over it quite soon. It’s now not possible to use the class for different requests. So I will add a constructor in a next version, allowing to pass a the base url when instancing the object. Also the response data object (pois) is not changeable via constructor variable -> need to be changed. (FYI: I used this class to load objects onto a visual map, therefore the name pointofinterst.) For now you can play with that code a litte bit an evaluate how it works for you as an AJAX alternative.

Categories
Dev

Android Tutorial

Kürzlich hatte ich das Vergnügen mich 1 Tag mit Google Android beschäftigen zu können. Dazu passend gibt es ein kleines Howto um auch anderen da draußen den Einstieg zu erleichtern. Voraussetzung für das Tutorial sind eine fertig installierte Eclipse IDE und Java Kenntnisse. Eine kleine Einführung was Android eigentlich kann und ist hab ich hier geschrieben.

Categories
Dev

High Performance MySQL bei Youtube

Paul Tuckfield,MySQL DBA bei YouTube über seine Erfahrungen mit MySQL:


als Podcast oder Video

Categories
Dev

Wechsel zu Netbeans 6

Gestern hab ich meine Java IDE Netbeans 5.5 durch die frische final Version von Netbeans6 ersetzt. Ich dachte es wäre ein leichtes Update mit einmal installieren und fertig – war aber dann schlussendlich nicht ganz so einfach. Grundsätzlich kommt Netbeans6 in schönen Installer Packages daher, wo ich mir gleich die All-Inclusive Version mit allen Zusatzmodulen geladen hab. Vorher noch NB5.5 und alle vorhanden Module deinstalliert und danach den umgekehrten Weg mit der neuen Version. Trotz das es auf der Downloadseite so gekennzeichnet war, ist Tomcat nicht im Bundle enthalten und muss seperat installiert und in NB als Server hinzugefügt werden. Standard Servlet Engine ist nun Glassfish2. Leider fehlt auch der Sun App Server aus dem Enterprise Package und muss ebenfalls seperat nach installiert werden. Da sich für mich alle Deployment Server geändert haben, musste ich sämtlichen Projekte ihre neuen Server zuweisen.

Was dagegen erfreulich einfach – wie in der letzen Version auch schon – funktionierte ist die Installation des WTK und Mobility Packs für J2ME Applikation (sehr interessant: Mobile Game Builder). Auch die ganz neue Ruby Unterstüzung ist schon fertig betriebsbereit und liefert als Beispiel “Das Depot” aus Agile Web Development with Rails, 2nd Edition mit.

Categories
Dev

Ajax Frameworks Roundup

In the past week some popular Ajax/JS Frameworks released new milestones. Here’s a litte summary of what happened:

Categories
Dev

Gehversuche mit Zend Studio Neon

Mit dem Zend Studio allgemein hatte ich ja immer meine kleinen Problemchen. Zend preiste ihr Produkt zwar ständig als die IDE für php Projekte an, doch bei mir hat das Zend Studio nie lange Platz auf meiner Festplatte gefunden. Offenbar ging es nicht nur mir so und Zend hat darauf reagiert und sein neues Zend Studio Neon komplett auf Eclipse Basis umgesetzt.

Der erste Eindruck ist bei mir schon mal recht positiv ausgefallen: alle Features die man von einer modernen IDE erwarten kann sind sauber umgesetzt worden. Aus alten Zend Studio Version bekannt ist wieder der interne php Debugger dabei, der aber im Neon besser in der IDE eingebettet ist. Generell hat man das Design Konzept der alten Studio Versionen verworfen und auf Eclipse typische Fensteraufteilung gesetzt. Was mich besonders freut ist die Zend Framework Integration und die Profiler View. Das Zend Framework, für alle dies noch nicht wissen, ist die php Antwort auf MVC. Dabei ist das Zend Framwork (gibt erst seit Sommer Version 1.0) das derzeit wohl am meisten ausgereifte MVC Framework in php, weit vor cakephp und auch sogar symphony. Darum wird es auch in Zukunft bei mir mehr zum Einsatz kommen, gemeinsam mit dem neuen Zend Studio Neon.

Categories
Dev

ExtJS Tryout

Ich war eigentlich schon lange auf der Suche nach einer schlanken webbasierten PM bzw. einer einfachen Task Verwaltung. Ich hatte es mal mit basecamp probiert – zu komplex und grausliche Bedienung; dann hab ich mir selber was gebastelt, was in meiner Liste der angefangenen und nie fertig gestellten Dinge eine schönen Platz findet.

Da Fabian schon länger von extjs schwärmt und ich es auch endlich mal gründlichst testen wollte, hab ich mir heute dafür etwas Zeit genommen. Und siehe da, oh wunderbarer Zufall, in den extjs Beispielen eine tolle, simple und genau für meine Zwecke passende Task Verwaltungs Applikation. Funkt dank Google Gears auch offline, also was will man mehr!

Ext selber macht auch einen schönen Eindruck auf mich. Ist um einiges schlanker und komfortabler zum handlen als Dojo hat aber auch ähnlich ansprechende Features.

Categories
Dev

Prototype 1.6.0 RC1

The first RC of prototype 1.6.0, the javascript Framework of my choice, is here with a bunch of exiting new features:

  • new Event System including custom Events
  • responseJSON method for Ajax Request to parse JSON String
  • in general better support for JSON as Ajax transport method
  • new DOM Mehtods for creating DOM Elements; Insertion and Positiona are deprecated
  • Template Engine
  • implementing of Javascript 1.6 features, eg. Array.indexOf is now nativly supported
  • ….

For more Infos read the Changelog or Sam’s announcment at the prototype blog.

Categories
Dev Thinktank

My Lifestream

erichs-lifestream_1185041050312.png

I read something about the idea of a so called lifestream in the adactio blog. Basically it is just a RSS Mashup with any feeds related to yourself. For example I have used some of my blogs and my del.ici.ous feed for it. And voliá, after a little bit of coding and a lot of css quirks my lifestream is now online.

To compare my work to others, you may have a look at the streams of Jeff Croft and Jeremy Keith.

Categories
Dev work & projects

Mindstorm Alpha

Last few days I have been working on a new small web applikation which is called mindstorm (hopefully lego won’t get angry cause their robotic building kit is called mindstormS). It is technically based on my openKE Framework and uses some Features like the Tagging System of it. Basically what you can do on mindstorm is to share ideas and opinions in the easiest way. There is no registration needed and synchronous and asynchronous working is posible.

Just looking forward to some people who just play arround with the appliaction and then tell me about bugs etc.