Monday, March 31, 2008

Worlds shortest Dojo 1.1 widget-writing tutorial

This is an attempt to be the worlds shortest tutorial on how to write your own Dojo 1.1 widget. It skips violently over dozens of key features. However, sometimes you just need a very small example that put things in perspective and then google for the rest as you need it. This is that tutorial :)

Sunday, March 30, 2008

Bunkai funkai

Things chug along. Not with any speed, but still.. I've now managed to get the Ext grid test up and run for Kirk at the World Change Network, which is very nice.

Also, I just realized that I had forgot to apply the template from Packtpub to the chapter I had such a hard time finishing. Within ten minutes my 21 pages was transformed into 45! Now that's what I call writing! :)

So it was finally time to continue to finish the Bunkai refactoring. When I released Bunkai it was a real dog, written shoddily inside the page and just barely working. I have now had time to do the following;

1) Create a Dojo Widget (Dijit) for the Bunkai editor as a whole, so it becomes dropable.
2) Create separate Dojo classes of all separate things (resources, editors and files, mostly).
3) Use superclassing to abstract away common functionality for all editors and resources.
4) Create a Google code repository and use svn for all code changes. Thanks Google ;)

Right now it works nominally, but only the menu shows. I have still to move in all old functionality, drag-drop et.c., but with all the work I've done today (and some evenings the last week) I expect the pace to pick up considerably. it feels really much cleaner to work with as a codebase already.

I've yet to start with creating a Dijit out of EditArea, so that part of the code just stays quietly in place and gets called as best I can.

I have high hopes of being able to ship a Bunkai version 0.3 which makes use of Lars Trieloff's excellent Apache Sling data store for resource loading and save later the coming week.

Then there's this really cool Friendfeed idea I've been toying with.

Ah, time...

Thursday, March 20, 2008

Breakthrough and some things you shouldn't miss

I finally decided how to create a component for WaveMaker that was both simple to create and simple to use. I choose to use a text string property that shows up and is editable in the studio IDE, which defines what submenus to create.

That means that if you enter "foo,baz,baz" in the property field for the menus, you will get a nice, resizable menu popping up in the IDE, with the submenus foo, bar and baz. No problem there.

I thought really hard on how to use the menus, and to show their use in a simple way within the WaveMaker IDE. I finally settled on using the wildly overlooked and insanely usable publish / subscribe message bus in Dojo 1.x

That meant that I had to create yet another component that listened for events from the menu component, but that's really OK, since it give newcomers something to copy and modiy without having to learn every little thing, which after all is what a HOWTO is about (IMHO).

So I took some screen dumps and wrote a short piece on how to create custom components using Dojo 1.x for WaveMaker. Source code and all.

Also, frustrated not to have a site to collect all available information on Thin Server Architecture, I created one, very quickly, using Google Apps. I didn't really intend to show it officially this early, but my collaborator Ganesh Prasad decided to let the cat out of the bag (which is the way things should go, of course. You can't just sit on things until they're 'ready', whatever that means ).

Then all of a sudden Matt Raible wrote a blog about it, and suddenly a lot of people get to see the fairly rough site. Also, as Matt succinctly puts it (my rewrite) ; it wouldn't hurt if a site that is all about client-side view did have one. To my defense I must hasten to add that at the moment we only have static information, which is fairly well handled by the server. Even I must confess to that :)

Then as the last absolute must-read today is Kris Zyp' blog about the upcoming, generic JSON web service description format, SMD, which will allow for pluggable web services, which is so cool it hurts. If you read only one thing today, read this!


Monday, March 17, 2008

Mentoring and Why is everything taking so long!

I got approved for mentoring someone for Google Summer for Code 2008. We're talking Dojo here, naturally. :) But I think it's a good opportunity to learn, according the age-old praxis that you learn the most when you're teaching someone else. Because of having to formulate yourself, et.c. It's going to be really interesting.

Some updates, then, if you're one of the hundred or so persons I've promised to do something for. Today I have:

1) Done real work for my day-time customers in the Dojo Charting, Widgeting and Gridding department: Yes
2) Writing on the Book (Learning Dojo from Packtpub): Yes, a little.
3) Finishing the fine and very simple Menu widget tool for WaveMaker Ajax Studio 3.1: No
4) Writing a simple PoC Grid for Kirk at the World Change Network: No
5) Refactoring Bunkai so that it can *finally* be included in Sling as an editor: Yes, a lot, but it's not enough.
6) Checking out the latest EditArea from Christophe and converting it into a Dojo Widget: No
7) Finishing the site, so it doesn't look like a complete dog : No
8) Actually playing some with my daughter who was home sick today while I mostly worked: Yes
9) Rallying more people to come to next Web Monday, and speakers as well, not to mention: No
10) Writing a simple mixin for JDA, to wire together Dojo widgets the JDA way for Slim: No
11) Showing my son how to operate the lockpad for his bathhouse excursion tomorrow before he fell asleep: Yes
12) Taking care to rest a lot to as to not fall prey to another cold: Yeah, right!

If you saw that your issues were on the 'red' side of this list, rest assured that tomorrow I'l switch everything around (again) :)


Thursday, March 13, 2008

Reasons for Thin-Server Architecture

This is a short description of how I am using TSA to help my clients rebuild their web applications to become more flexible and to be built quicker.

I recently started working with a new client in Stockholm who needed to revamp their administrative dashboard for their customers (it's an ad network company). Currently they have a fairly classical Struts application which rebuilds the whole page on every click. The dashboard is very graph and chart intensive, whose graphics had been created by JFreeChart on the server.

The first things I would like to comment on here is the time it takes to make changes. Any change to any file results in a 15s. restart of the local Tomcat to see that it doesn't break anything immediately, and then the built WAR is ssh'ed over to the live system (where the large databases reside, which are not to be used for development but which is needed to see any non-trivial results), which takes about a minute. yes it's slow. Yes, I know. But that's the way it is.

Sometimes you have to restart the server on that side as well when hot deploy doesn't work properly, but that's life. It doesn't happen very often. However, just to see how a change looks on the server takes at least two minutes, possibly more, and that's not a long time, really. it's just that it breaks the concentration of the programmer.

What I did was to arrange with the person responsible for the Struts application (which, incidentally was both smarter and cooler than I was, having done quite a lot of server, demo scene and mobile coding and understood or clarified everything I came up with to talk about, something I really like and don't get enough of. Really :) and managed to get a couple of actions from the server which only returned XML. Naturally we talked a bit of the content, but it was fairly quickly sorted out.

Then I copied the output
of each action and saved to a local file under a directory I called "mock-server". The I made a custom Dojo widget for each action, to massage and dress up the data as need be, which used "Ajax" to read the file from the local directory instead, but which used a parameters to set the url, so it would be simple to change when in production.

The point I'm being very long-winded in making, is that I can now make any number of changes to my widget, using real(ish) data, without breaking my concentration. Also, local page reloads are about as fast as you get when it comes to turn-around time.

What happened at the same time was that there was no way that changes to the server, a reboot of the dev environment, et.c. would bother me in the least. Also, any changes I doodle with locally have no impact on any testing going on, _and_ we just agreed upon a protocol to use, instead of an API, which is much more flexible.

Consider that one of their customers would like to use the data that we use to create Grid tables directly and pipe it into their SOA framework. Go ahead. it's already there. And it took us all of fifteen minutes to agree upon and document it. We have also separated the View from the rest of the logic and put the View on the client (in the browser), which makes things *snappy*.

One of the components was a customized Dojo grid with some formatters for pictures and links, and the other was a fairly large wrapper for several types of chart (You have to look up the Charting API examples in Dojo 1.x, they're simply stunning), and all I get from the Struts server is XML. So I just shrunk the server a bit.

The next step is to remove all JSP processing _except_ the XML feeds (which will use authentication, naturally. Doh!) from the server, which will let the server-side guy concentrate on business logic only, and make the client less magical, being only a bunch of JavaScript and CSS files.. and ONE html file.


What happens here is that you get separation of concerns at a very basic and natural level, you get quicker coding for at least parts of the system, and you get a authenticated XML feed of the most important data in the system, ready to pour into an enterprise bus or what have you.

Anyway I have a gazillion other things to juggle before falling asleep, Just two quick points;

1) If you're in Sweden, don't forget next Web Monday the 1st of April!
2) I'm going to Google I/O 28/29 May in San Fransisco! Yay!!!! :) Possible with the whole family as well. If you're going to be there, drop me a line and well meet up for a beer.

Sunday, March 9, 2008

Nailed them Menus

Finally, after having a dozen 15 - 30 minutes sessions with different attempts at creating my own custom menus with WaveMaker, I managed to do them - almost as I wanted.

I think the big problem was that I began with implementing a lot of function I thought I needed, thereby overriding mixins and superclasses (yes, I forgot to call them, ta!).

Then I carried on in same vein, by mismanaging the information about which element to use for what, et.c. Now that the menus are (sort of) there, I need to do the following;

1) Dig up my old JDA Composer II template, where I had menus up and down the page and copy some code,
2) Find out a way to easily connect event to the menus (Can probably snarf stuff from existing components)
3) Meditate upon the best way to add new menus and submenus (i already have a custom 'submenu' widget which I can use as substrate)

But all in all, I managed to nail one out of 120 point in my wish list - not bad!

Things I would like to do

1. Finish my refactoring of Bunkai
2. Understand how the %!#¤! to create a Dojo Menu widget for WaveMaker and deliver a howto. This year.
3. Write the remaining 35 pages of chapter two of my upcoming book "Learning Dojo", to remain this side of the deadline.
4. Not work on the weekend for my current client
5. Finally get my new laptop delivered, so I can work on my pet projects on the train - Yay!
6. Get up the links for last Web Monday
7. Get more exercise
8. Grow more hair, fix Pippi Longstocking braids.
9. Get rich, so my wife can go riding all day.
10 - 120. Variations of the above.