Update an image with AJAX/Comet (server push)

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

Update an image with AJAX/Comet (server push)

Jochen
Hallo,

I'm developing a web application in that i need to update an image element very often but neither periodically nor on user input. The image gets computed on the server as a Form-object. I'm trying to realize this with Comet:

    TestApp>>renderContentOn: html
        html span
            id: #display;
            with: [ html image form: (self getDisplayForm) ].
        html submitButton
            onClick: (html request callback: [ self update ]);
            with: 'update'.
        html script: (html comet
            pusher: self pusher;
            connect)

    TestApp>>update
        self pusher javascript: [ :script |
            script element
                id: #display;
                update: [ :html | html image form:
(self getDisplayForm) ] ].

The method 'getDisplayForm' computes a new Form-object on the fly.

When I click the Button 'update' it works as expected (the form gets computed and the image on my website updates immediately). But when I perform the 'update' method from outside this class (every time when a new image is available that is computed somewhere else), I get this error:

    UndefinedObject>>doesNotUnderstand: #application
    WARenderingContext>>registry
        ^ WACurrentSession value application
    WARenderingContext>>urlForDocument:mimeType:fileName:
    ...

Afaik the problem is the missing WACurrentSession and because of that it's not possible to compute a temporary URL for the image.

But I don't understand, why one time my 'update' method works (after the button click) and one time not (when I perform the 'update' method directly).

Can anybody explain this strange behavior? Or does someone have another idea how I can update an image with server push (without user input or site reload)? I would be very very happy to get some new ideas! - It's an important part of my master thesis..

Jochen



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

Re: Update an image with AJAX/Comet (server push)

Lukas Renggli
> Can anybody explain this strange behavior? Or does someone have another idea
> how I can update an image with server push (without user input or site
> reload)? I would be very very happy to get some new ideas! - It's an
> important part of my master thesis..

In the first case (when you press the button) you are in the context
of a session, thus the application is also know. In the second case
the application is not know, presumably because you call the method
from some background thread.

Probably you could avoid the error by somehow faking a session so that
the URL could be generated the usual way. Alternatively you could
register the URL yourself with your application object by navigation
through the dispatcher to the application.

Hope this helps,
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: Update an image with AJAX/Comet (server push)

Jochen

Can anybody explain this strange behavior? Or does someone have another idea
how I can update an image with server push (without user input or site
reload)? I would be very very happy to get some new ideas! - It's an
important part of my master thesis..
    

In the first case (when you press the button) you are in the context
of a session, thus the application is also know. In the second case
the application is not know, presumably because you call the method
from some background thread.

Probably you could avoid the error by somehow faking a session so that
the URL could be generated the usual way. Alternatively you could
register the URL yourself with your application object by navigation
through the dispatcher to the application.

Hope this helps,
Lukas

  
Thank you Lukas! I've spend the whole day with digging deeper into Seaside but unfortunately I couldn't find a solution yet. I was neither able to get a link into the current session context nor faking another session. I just don't know how to do it. I also tried your other idea to register the URL myself. But then I've no idea how I could get this work with Comet to update the image on my website. Maybe - if you've some time - you could give me some more help with this... 
Jochen

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside