[Seaside] Seaside + Scriptaculous: Question on SUAjax onLoad, onComplete, etc.

Leandro Pérez lperez at lifia.info.unlp.edu.ar
Tue Jun 26 20:40:09 UTC 2007


Hello, first of all, please forgive me for this extensive post, i didn't know
how to explain my problem

I need to achieve the following: 
When clicking a submit button, some server side actions must be performed
and meanwhile those actions are being executed the user must see in
different places of the web page different things, i.e. animated gifs
showing progress, information text etc.. all this without refreshing the
whole page, using ajax.  After the server side actions are executed, all
those things that depended on the actions must be again refreshed according
to the new model state in the server, using ajax.
e.g. 
in a web messenger different images showing some contact's information
a button that when clicked launches some changes on the model (sever side)
when the button is clicked each image shows an animated gif meaning
something is being done
when the server side action is finalized the images are refreshed showing
the contact's new state

currently i'm doing something like this..

(html div) 
    id:'some_div'
    with:'Some information'.

(html submitButton)
    onClick: ((html evaluator)
	callback: [:script | self performSomeServerSideActions. 
                                 "THIS TAKES A WHILE"];
	onLoading: (html evaluator callback: 
	     [:script | 
              (script element)
	         id: 'some_div';
	         render: [:r | self renderWorkingStatusOn: r 
                                 "THIS GENERATES HTML DEPENDING ON THE MODEL
STATE ON THE SERVER"]]));
	onComplete: (html evaluator callback: 
	     [:script | 
              (script element)
	         id: 'reels';
	         render: [:r | self renderNewStatusOn: r 
                                 "THIS GENERATES HTML DEPENDING ON THE MODEL
STATE ON THE SERVER"]]));
    text: 'Spin'.


The problem of this is that the onLoading actions are not executed before
the callback, but after, and because the onComplete actions are executed
after the onLoading actions, the "working status" or the progress is not
shown.

I also did this...using element instead of evaluator

(html submitButton)
    onClick: ((html evaluator)
	callback: [:script | self performSomeServerSideActions];
	onLoading: ((html element)
	         id: 'some_div';
	         render: [:r | self renderWorkingStatusOn: r
                                  "THIS GENERATES HTML DEPENDING ON THE
MODEL STATE ON THE SERVER"]]));
	onComplete: (html evaluator callback: 
	     [:script | 
              (script element)
	         id: 'reels';
	         render: [:r | self renderNewStatusOn: r
                                 "THIS GENERATES HTML DEPENDING ON THE MODEL
STATE ON THE SERVER"]]));
    text: 'Spin'.

This partially works, i mean that it shows the progress and working stuff
but with some inconsistences. The problem is that the code inside the first
render block ([:r | self renderNewStatusOn: r]) is executed when the
onLoading message is sent and the results are part of the generated js, this
causes that the generated html that will be shown when the actions are
executed is not consistent with the real model state, but with the former
state (the one existing at the time the page was rendered and the js
generated)

does anybody knows how to make this work or how to do it in a better way?

I don´t really know if the way i'm trying to do this is right, so if anyone
has a better idea it will be great!


i'm currently using
        VisualWorks NonCommercial, 7.5
        Seaside2.7b1
        Scriptaculous2.6-mb.8

Thanks,
Leandro 
-- 
View this message in context: http://www.nabble.com/Seaside-%2B-Scriptaculous%3A-Question-on-SUAjax-onLoad%2C-onComplete%2C-etc.-tf3984652.html#a11313378
Sent from the Squeak - Seaside mailing list archive at Nabble.com.



More information about the Seaside mailing list