[Seaside] SeasideAsync and Scriptaculous

Lukas Renggli renggli at gmail.com
Wed Nov 22 09:59:52 UTC 2006

Some corrections ...

> Also there are many differences in how the ajax things are done by
> SeasideAsync and Scriptaculous. For the ajax things, SeasideAsync
> has two concepts : live requests and event trackers, Scriptaculous
> has four (i.e. updaters, requests, evaluators and periodicals).

In fact periodicals are not a new concept, they are just updater that
get executed periodically. In fact, I plan to deprecate the periodical
updater, and use a periodical decoration that can then be used with
any Javascript object. This is also the direction that the JavaScript
library is going and the latest PeriodicalUpdater is implemented with.

> This means that a Scriptaculous updater can only update one
> html element at a time. If you need to update multiple html elements
> in a page, then you need to stack multiple updaters like this
>                 onClick: ( html updater ...);
>                 onClick: ( html updater ...);

No one would want to write it like this, it is very inefficient as it
creates multiple requests. This is why there is the evaluator:

   onClick: (html evaluator callback: [ :script |
      script element id: 'counter1'; render: count1.
      script element id: 'counter2'; render: count2 ])

Note that you can do also a lot of other things, besides just updating
the contents of a tag.

- replacing/removing the tag
- inserting contents above or below the tag
- inserting contents at the top or bottom within the tag
- adding/removing a css class from a tag
- toggle the visibility, scroll to the element
- apply all kinds of effects on the element

> This callback generates an HTTP response containing a well-formed
> XML document. This XML document is parsed and the contents of each
> xml element found with an id= attribute is used for replacing the
> matching

The generated HTTP response of the above code is a well formed
text/javascirpt document, that gets executed in the context of the Web

> If the XML document produced by the live callback happens to contain
> some script elements, these scripts are always evaluated (unlike
> Scriptaculous that requires sending #evalScripts: true to the updater).

That can be changed on the Smalltalk side, it is just the default
behavior of the JavaScript libraries.

> Another difference between the Scriptaculous updater callback and the
> SeasideAsync callback. The Scriptaculous callback takes only one
> argument,
> the canvas where to write the response. The SeasideAsync takes two
> arguments,
> an event object and the canvas where to write the response. The event
> object is
> an instance of WALiveEvent and describes the actual event that
> triggered the
> live callback. It holds information about when the ajax occured in
> the client,
> what type of event, what html element triggered the event, what type
> of element,
> the value of the html element...

There is an unlimited number of parameters that can be serialized at
once, that's what the callback and trigger-protocol is for. It allows
to transfer any JavaScript/DOM/Browser state (not just the current
event) to the client. There are convenience methods that automatically
map DOM elements to Smalltalk object, so you can get much fancier
things than just a string ... real Smalltalk objects.


Lukas Renggli

More information about the Seaside mailing list