[Seaside] immediate display alert to user while Ajax request

jtuchel at objektfabrik.de jtuchel at objektfabrik.de
Sun Jul 23 09:15:16 UTC 2017


Sabine,

I think you need to fork  a new (background) process in order to have it 
run independently of the Ajax callbacks. The Ajax callbacks will be 
executed one after the other, there will never be any progress reporting.

So I THINK what you absolutely have to do is to start the long running 
Ajax callback as another process.

So start by putting your sequence of process steps in a

[
  ] fork.

block and see if it improves things.


I am using an inst var of the component instead of the session, but I 
guess that doesn't really matter. Using the session is probably a much 
better idea because you could then use this facility for a general 
solution that works for all ajax callbacks that run longer...


HTH

Joachim



Am 21.07.17 um 17:31 schrieb Sabine Manaa:
> 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: Re: immediate display alert to user 
> while Ajax request 
> <http://forum.world.st/immediate-display-alert-to-user-while-Ajax-request-tp4956083p4956113.html>
> Sent from the Seaside General mailing list archive 
> <http://forum.world.st/Seaside-General-f86180.html> at Nabble.com.
>
>
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


-- 
-----------------------------------------------------------------------
Objektfabrik Joachim Tuchel          mailto:jtuchel at objektfabrik.de
Fliederweg 1                         http://www.objektfabrik.de
D-71640 Ludwigsburg                  http://joachimtuchel.wordpress.com
Telefon: +49 7141 56 10 86 0         Fax: +49 7141 56 10 86 1

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/seaside/attachments/20170723/a285f814/attachment-0001.html>


More information about the seaside mailing list