[Seaside] immediate display alert to user while Ajax request

Sabine Manaa manaa.sabine at gmail.com
Mon Jul 24 10:18:28 UTC 2017


Hi Joachim,

you are right. This was the point.

I had another problem with getting the session in the forked process. I
asked in Discord and Max Leske helped.
To geht the session, I have to do the following in the Ajax request:

| requestContext |
 requestContext := WACurrentRequestContext value.
[ WACurrentRequestContext use: requestContext during: [ self session
dosomething ] ] fork.

Thank you for your help!
Sabine

2017-07-23 10:55 GMT+02:00 jtuchel [via Smalltalk] <
ml+s1294792n4956392h47 at n4.nabble.com>:

> 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[hidden email] <http:///user/SendEmail.jtp?type=node&node=4956392&i=0>http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
>
> --
> -----------------------------------------------------------------------
> Objektfabrik Joachim Tuchel          [hidden email] <http:///user/SendEmail.jtp?type=node&node=4956392&i=1>
> 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
>
>
>
> _______________________________________________
> seaside mailing list
> [hidden email] <http:///user/SendEmail.jtp?type=node&node=4956392&i=2>
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://forum.world.st/immediate-display-alert-to-user-while-Ajax-request-
> tp4956083p4956392.html
> To start a new topic under Seaside General, email ml+s1294792n86180h75 at n4.
> nabble.com
> To unsubscribe from Seaside, click here
> <http://forum.world.st/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=1310907&code=bWFuYWEuc2FiaW5lQGdtYWlsLmNvbXwxMzEwOTA3fC0xOTE3OTcxOTg5>
> .
> NAML
> <http://forum.world.st/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://forum.world.st/immediate-display-alert-to-user-while-Ajax-request-tp4956083p4956534.html
Sent from the Seaside General mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/seaside/attachments/20170724/98a74d5d/attachment.html>


More information about the seaside mailing list