[Seaside] Re: Sending messages to javascript objects

Igor Stasenko siguctua at gmail.com
Fri Apr 25 18:20:03 UTC 2008

2008/4/25 itsme213 <itsme213 at hotmail.com>:
> "Andres Fortier" <andres at lifia.info.unlp.edu.ar> wrote in message
>  > Now, even though possible, in some cases it is a waste of user time and
>  > bandwidth to re-render a whole component
>  Updater can update any element with an html id, even an individual checkbox.
>  e.g.
>  onClick: (html updater
>     id: tinyElementId;
>     callback: [ : r | self renderTinyElementOn: r]);
>  You can assign elements ids while they are being rendered using
>     html nextId

This is not an option for given case.
Using scripts for handling user interaction is good way to prevent
excess network activity and we need to think about, how
to make it more easy.

>From my own experience this was not very easy.
In my case, when user clicked on button , i wanted to show an element
if it's not visible, and hide it if it was visible.
In own turn an element contents, when shown first time, should be
loaded using updater, so initially page doesn't contain everything and
this is not plain simple show/hide switch.
The script which i produced was a bit long (check element visibility,
call updater when showing first time and after update finished, make
it appear with fancy effect), and it would be much better to place it
in separate js function, otherwise, if i having 20 switches on page,
page contains too much repeating code.

So, i proposing something like:
onClick: (html callMethod: #foo of: self  with: self element id with:
10 with: 20)

now, a MyComponent>>foo:x:y: can look like:

'function foo (element, x, y) {
   element.position.x = x; element.position.y = y; } '

And in HTML, seaside should generate something like:
.. <tag ... onClick = "foo(5,10,20)"> ..

And finally, don't forget that we need to add new script to #updateRoot:

updateRoot: htmlRoot
  htmlRoot addScript: self foo.

What i don't like in code above:
- script it is added manually, it would be more convenient to add it
automatically (as result of call to html callMethod: #foo of: ...)
- html root having no option to inline script in html, instead it
generates <script src=..>, it would be good to have an option (a
method, like WAHtmlRoot>>addScriptInline:, which will generate script
with source inlined on page, because browser losing much more time to
load script using separate request rather than simply parse few lines
of code , and if your page contains too much scripts , a page load
time can be  slowed down dramatically.

>  Hth,
>  Sophie
>  _______________________________________________
>  seaside mailing list
>  seaside at lists.squeakfoundation.org
>  http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

Best regards,
Igor Stasenko AKA sig.

More information about the seaside mailing list