Automating ajax component updates

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Automating ajax component updates

Sophie424
I am trying to push Ajax in non-localized page changes e.g. a single Ajax
callback can result in several components on a page being re-rendered. Is
the following approach semsible?

1. components listen for announcements from their model objects
2. any interesting model object change is batched by the component someplace
when the change is detected
3. all batched changes from 2 are re-rendered at next chance

I'm a bit stuck on two points:

A. Where #2 should build up the batch. Seems like a Page object would be
ideal. Is such a thing accesible (root of the component tree)?

B. How #3 can get the appropriate canvases to render upon. Should I do
something like this:
 html evaluator callback: [ :s |
   batchedItems do: [ :changedComponent |
     s element id: changedComponent id; update: ??? ]]

What should the "???" look like? I don't think I have a canvas to render on
at this point.

Thanks - Sophie



_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Automating ajax component updates

Lukas Renggli
> A. Where #2 should build up the batch. Seems like a Page object would be
> ideal. Is such a thing accesible (root of the component tree)?

You are talking about announcements, but it doesn't look like you use
the announcements framework.

> B. How #3 can get the appropriate canvases to render upon. Should I do
> something like this:
>  html evaluator callback: [ :s |
>    batchedItems do: [ :changedComponent |
>      s element id: changedComponent id; update: ??? ]]
>
> What should the "???" look like? I don't think I have a canvas to render on
> at this point.

??? can be anything renderable: a string, a component, a block, ...

In case of renderable blocks they might use zero or one argument  (see
BlockContext>>renderOn:) where the argument is the canvas to render
on.

Cheers,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Automating ajax component updates

Sophie424

"Lukas Renggli" <[hidden email]> wrote in message
>> A. Where #2 should build up the batch. Seems like a Page object would be
>> ideal. Is such a thing accesible (root of the component tree)?
>
> You are talking about announcements, but it doesn't look like you use
> the announcements framework.

I am using the version from your repository. Where would you recommend I
accumulate the changed components until they get re-rendered?

>>  html evaluator callback: [ :s |
>>    batchedItems do: [ :changedComponent |
>>      s element id: changedComponent id; update: ??? ]]
>>
>> What should the "???" look like? I don't think I have a canvas to render
>> on
>> at this point.
>
> ??? can be anything renderable: a string, a component, a block, ...

Wonderful, thank you.

Does the approach above seem reasonable?

Sophie



_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Re: Automating ajax component updates

Lukas Renggli
> I am using the version from your repository. Where would you recommend I
> accumulate the changed components until they get re-rendered?

You need some place to put the announcer. Depending on your
application either a custom session class or the root component might
be appropriate.

> >>  html evaluator callback: [ :s |
> >>    batchedItems do: [ :changedComponent |
> >>      s element id: changedComponent id; update: ??? ]]
> >>
> >> What should the "???" look like? I don't think I have a canvas to render
> >> on
> >> at this point.
> >
> > ??? can be anything renderable: a string, a component, a block, ...
>
> Wonderful, thank you.
>
> Does the approach above seem reasonable?

Yes, I've done this many times. Whenever an event happens you
initialize an announcement with the script of the evaluator. Anybody
interested is subscribed to this event and can add code to the script
to update itself.

Cheers,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside