Thursday, May 24, 2007

XUL for Rails

presented by Max Lansing

Resources:

XUL Hello World app at:
http://maxlansing.com/xul_helloworld.zip

My Summary:

XUL gives you a way to have sexy fat-client widgets but, you are restricted to Mozilla
browsers only and you have to hack prototype.js to use it with XUL. It is pretty simple
to use Rails as a back-end system with XUL since Rails just sends XUL XML documents.

My Notes:

pronounced Zool

Why not just use HTML?
It's nice to have a native-feeling app
and
not have document pages

Grid-based box model, not document (more trouble)

good for non-designers

localization is simple (use XML entities in place of ordinary strings with DTD activated for a particular context)

can always fallback on XHTML

thorough documentation, supportive community

Drawbacks:

Mozilla Only
slight learning curve
gotta hack prototype.js
builder xml render slow, can use erb instead
some bugs, niche technology means fixes may not get the same attention as other mozilla bugs


XBL defines XUL tags, can make your own
looking at XBL is a good way to learn how XUL is implemented

Deployment a Headache? yes

To use Rails as back-end:

Use .rxml or erb
need to specify global chrome skin
XUL response headers right
respond_to, :format, cannot use these (you get a 406)
that's it, rails is sending xml documents and doesn't care about anything else

Prototype woes:

Function.prototype.bind() doesn't work as XUL windows are precompiled and don't delegate to Function.prototype.bind()

Workarounds:

declare functions using new Function() - huge maintenance headache
or
patch prototype.js, rewriting Function.bind as freestanding function
or
patch prototype and scriptaculous dynamically (he's written one and will give it to us)

Element.replace() or Element.update() - doesn't work in XUL

Form.serialize() and Form.Element.serialize() - not available for XUL

XUL doesn't have forms, window and elements are your form

except for trickiness with javascript updates, you could write an app that has both a XUL and HTML front-end
XULrunner for offline apps

No comments: