spacer spacer spacer

2005-05-07

About that serverless app...

In Now We Are Three, I pointed out that Laszlo apps could now be ‘serverless’, meaning they can be compiled to a standalone .swf that can be delivered by any web server (no J2EE servlet required) and that they can fetch XML data directly from any http: data source. I pointed out that I should rewrite my little ptunes app (in the left column) to be serverless, and that I would report on how hard it was. Well, here’s the report:

It should have been simple. I should have been able to just put in the <canvas> tag proxied="false" and recompile. It would have been that simple if my app code were not nearly two years old. The <tabslider> component that I used in my app has evolved a lot in that time, so I had to spend a bunch of time ripping out kludges that I had in my code to work around some of the limitations of the old implementation.

In the end, it was a great improvement. I eliminated a lot of excess baggage. I was able to use the new <style> component to give my app a uniform style. I was able to use the new resizable canvas feature to let my app take its size from the <object> tag that embeds it, rather than having a static size. I was able to eliminate a lot of nested views because I just understand LZX better now.

I did have to change the code that calculates the source URL for my ‘Show Source’ button. It has to change the file suffix from .swf to .lzx. I was fooled for a second on why my tooltips faded in and out in such a funky fashion, then I remembered that <text> now defaults to device fonts and I guessed that device fonts don’t respond to opacity changes any more than they respond to rotation. I changed my tooltip font back to an embedded font and all was well.

The one thing that stumped me the longest was figuring out how to get the ‘Now playing’ track to be the tab that is open on loading. I poked around in the documentation and on the web for a while and found a whole bunch of techniques for dealing with the fact that because replication happens lazily, nearly anything you try is going to set the selected ‘too soon’. Setting defaultselected in the tabslider doesn’t work. Setting it in and ondata clause in the tabslider doesn’t work. Setting it in an onclones in the datapath doesn’t work. Aha. You can’t set it until the tab that you want to set to has been inited. I finally hit upon it: in the <tabelement> I put:

oninit="this.setAttribute('selected', this.tip == 'Now playing')"

Phew. The tough part is that sometimes it seemed to work, when I was debugging locally — presumably because the data arrives fast enough — but when I would install the app on my server, it stopped working.

The last step to getting my SOLO app to work was simply to upload it (and the source!) to my server (Just used Interarchy to do that) and then adjust my <object> tag to fetch the app locally (instead of through mylaszlo). Oh, I could shorten the opml address to a relative address. You see the result to the left.

I’m still using Kung-Tunes to upload my XML, but that is obsolete. So the next effort will be to, hm, can I use DynDNS to make my laptop visible and have ptunes query my iTunes directly for what’s playing? Hm…

Post a comment

Thanks for signing in, . Now you can comment. (sign out)

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)


Remember me?


You are not signed in. You need to be registered to comment on this site. Sign in