Answer Handlers - Multiple?

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

Answer Handlers - Multiple?

Sean P. DeNigris
Administrator
IIUC there can only be one answer handler for a component because
WAAnswerHandler>>#handleAnswer:continueWith: doesn't touch the second
argument, causing #handleAnswer: to skip the rest of the decorator chain by
returning true.

Is that a design decision? It seems like it could be useful to have multiple
answer handlers…



-----
Cheers,
Sean
--
Sent from: http://forum.world.st/Seaside-General-f86180.html
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Answer Handlers - Multiple?

Esteban A. Maringolo
Hi Sean,

On 29/06/2018 10:49, Sean P. DeNigris wrote:
> IIUC there can only be one answer handler for a component because
> WAAnswerHandler>>#handleAnswer:continueWith: doesn't touch the second
> argument, causing #handleAnswer: to skip the rest of the decorator chain by
> returning true.
>
> Is that a design decision? It seems like it could be useful to have multiple
> answer handlers…

What would be the use case of such multiple handlers?

I've been doing some pretty complex UI interactions lately, and with the
extend use of AJAX callbacks I'm barely using the call:/answer: pattern.

Regards,

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

Re: Answer Handlers - Multiple?

Sean P. DeNigris
Administrator
Esteban A. Maringolo wrote
> What would be the use case of such multiple handlers?

I have a Magritte form for a Command object. I wanted to execute the command
during #save, which is implemented like this:
    ...
    self commit; answer: self model

I needed to execute after the commit but before the component answers. I
tried with an #onAnswer: block, but that prevented the normal answering, so
I ended up basically copy/pasting to:
MyModelObject>>#loginVia: aWAComponent
        "This is pretty much what #save-ing the Magritte form does, but there was
no apparent hook to set the user"
        ...
        aWAComponent commit.
        self ifUserAuthenticated: [ :usr | aWAComponent session user: usr ].
        aWAComponent answer

And then:
MyModelObject>>#asComponent
        ^ super asComponent
                        addValidatedForm: { [ :comp | self loginVia: comp ] -> 'Login' };
                        yourself




-----
Cheers,
Sean
--
Sent from: http://forum.world.st/Seaside-General-f86180.html
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Trigger a method from javascript

Pierre Durand
In reply to this post by Esteban A. Maringolo
Hi

I have a nice UI using Pharo/Seaside ans I’m able to control the program flow with AJAX callbacks on the UI but only when there are user actions.
The are some asynchronous processes in javascript (server connexion, file downloads) and I would like to trigger some methods in the pharo code when they complete.
What are the options ? Do i have to trigger some event ? How do I read/listen to them ?

Thanks !

Pierre

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

Re: Trigger a method from javascript

Paul DeBruicker
using a combination of  JQueryInstance>>#on:do: &  JQAjax>>#callback:value:
can probably do what you want.    See the jQuery docs for how on() works and
what it can return if you haven't .

https://api.jquery.com/on/


e.g.

.

html document
    addLoadScript:
      (html jQuery expression:'body')
              on: #('myEvent')
              do:((html jQuery ajax
                       callback:[:val | self handleJSEvent:val]
                              value:('return event' asFunction: #('event'));
                   onSuccess: (self renderViewChangesOn: html))


and then your method to get changed data back to the DOM from that could be


renderViewChangesOn: html
    ^ html jQuery ajax script:[:s | s << self myScriptToUpdateTheDOM: s]



and the #value: portion above can just be a reference to a js variable in
the DOM if you replace it with

(JSStream on: 'myVariable')


Hope this helps




Pierre Durand wrote

> Hi
>
> I have a nice UI using Pharo/Seaside ans I’m able to control the program
> flow with AJAX callbacks on the UI but only when there are user actions.
> The are some asynchronous processes in javascript (server connexion, file
> downloads) and I would like to trigger some methods in the pharo code when
> they complete.
> What are the options ? Do i have to trigger some event ? How do I
> read/listen to them ?
>
> Thanks !
>
> Pierre
>
> _______________________________________________
> seaside mailing list

> seaside@.squeakfoundation

> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside





--
Sent from: http://forum.world.st/Seaside-General-f86180.html
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside