[Seaside] immediate display alert to user while Ajax request

Paul DeBruicker pdebruic at gmail.com
Fri Jul 21 15:50:17 UTC 2017

Hi Sabine,

You might want fork the report processing using a ThreadPool e.g.
http://onsmalltalk.com/2010-07-28-a-simple-thread-pool-for-smalltalk  Code
is here: http://smalltalkhub.com/#!/~pdebruic/ThreadPool

And then in your 'update the message to the customer polling' code also poll
for the reports to be complete and have that code update the page once they

The ThreadPool, when running, does use some CPU, maybe more than it should,
and I haven't looked into why yet.

Hope this helps.  


Sabine Manaa wrote
> Hi Joachim, all,
> thanks a lot! I think I am very near to the solution but there is one
> problem remaining: within the Ajax block, the JQLoad   seems to be
> "blocked". I explain:
> * I have an attribute @directUserMessage: in my session initialized with
> an
> empty string.
> *In my main view I have >>renderLoadIntervalMessageOn: html
> html paragraph
> id: 'spf-direct-message';
> script:
> (html jQuery this load
> onComplete:
> (' javascript which shows the snackbar if spa-direct-message is set'));
> html: [ :r | self renderMessageOn: r ];
> interval: 1 seconds);
> with: [ self renderMessageOn: html ]
>  >>renderMessageOn: html
> self session directUserMessage isEmpty
> ifFalse: [ html render: self session directUserMessage ]
> I have my button invoking the report generation:
> onClick:
> (html jQuery ajax
> script: [ :script |
> self session generateReportFiles: script.
>  ...]);
> with: 'PDF'.
> in >>generateReportFiles:
> "i set the directUserMessages:"
> self session directUserMessage: 'Erstelle Reisekostenabrechnungen, bitte
> warten...'.
> RKAPDFWriter new createCostReports: self.
> self session directUserMessage: 'Erstelle Belege, bitte warten...'.
> RKAPDFWriter new createReceiptReports: self.
> self session directUserMessage: 'Erstelle Fahrten, bitte warten...'.
> RKAPDFWriter new createVehicleReports: self.
> self session directUserMessage: 'Erstelle Buchungen, bitte warten...'.
> RKAPDFWriter new createBookingReports: self.
> self session directUserMessage: ''
> I tried I with a test button:
> html mdlButton
> onClick:
>  (html jQuery ajax script: [ :script | self session directUserMessage:
> 'test' ]);
> with: 'set message'
> this works perfect - after clicking on the test button, the snackbar is
> showing every second again.
> So, I can say that the principle was clear and I have a possibility to
> show
> individual messages by setting the string in the session.
> BUT: while I am in the Ajax block, it does not work.
> I put a console.log() into the javascript code and AFTER finishing the
> Ajax, all the messages are put there.
> It seems to wait till the Ajax call is finished.
> I have put an output  into the transcript:
> renderMessageOn: html
> Transcript crShow: Time now printString , '-' , self session
> directUserMessage.
> and there I see, that while I am in the Ajax block, there is no output.
> While I am not in the Ajax block, it renders the time into it each second.
> What is wrong here, can anyone explain?
> Joachim, do you also set the instance variable with the text from an Ajax
> block?
> Regards
> Sabine

View this message in context: http://forum.world.st/immediate-display-alert-to-user-while-Ajax-request-tp4956083p4956118.html
Sent from the Seaside General mailing list archive at Nabble.com.

More information about the seaside mailing list