Tuesday, November 02, 2010

OB-Web - JavaScript/AJAX/Smalltalk server example

Anything goes web ... even IDE's like Eclipse (see Eclipse e4).

"Smalltalk labs" has implemented an enhanced web based code browser for the Seaside web framework for Smalltalk. Compared to the standard web based browser tool that comes with the Seaside web framework the one from Smalltalk labs uses AJAX to navigate through the browser which means it feels more like an application than a website.

Coding directly in the webbrowser is still cumbersome - so I prefer the Smalltalk based browser installed in the image and only use the web tools when I have to check an image remotely.

However ... since browsing Smalltalk directly in the webbrowser is easy to do Lukas today updated the packages for "OB-Web" to use OmniBrowser (the Smalltalk browser used in Pharo) to be accessible from a webbrowser too.

Just download Pharo 1.1. and follow the simple instructions to run it and see yourself.

Browsing the code you will find out that it is a nice example how to use the Comanche webserver (KomHttpServer) to write own web based services. It's also a nice example for AJAX communication between client side JavaScript and server side Smalltalk code using JSON.

Some hints for checking out the code:

  • "OBKomHttpService startOn: 9090" starts the app on the given port so you can navigate to http://localhost:9090
  • OBKomHttpService also adds logic for startup/shutdown at image startup/shutdown
  • in the superclass OBHttpService there is (depending on the web path) a launcher created (see OBWebLauncher>>contents for the generated HTML page)
  • the page uses http://localhost:9090/library/link.js and http://localhost:9090//library/launcher.js where the first one is responsible for the XMLHttpRequest (AJAX)
  • both scripts are served by Smalltalk as well (see OBLinkFile and OBLauncherFile)
  • the AJAX requests are handled in OBHttpService>>processAjax:for:
  • subclasses of OBInteractionRequest handle requests like menues, etc.

Really cool example for JavaScript/Smalltalk combination.

No comments:

Post a Comment