Callback onError: management

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

Callback onError: management

Trussardi Dario Romano
Ciao,

i development with Seaside 3.3 into Pharo 703.

I have an anchor with specific ajax callback:   block.
Now I’m interested to rendering different data if the callback code erase some error or not.
I do some test with this code but the onError: script data is always rendering.


renderSubTableAnchorFor: aName class: class on: html

html anchor
onClick:( html jQuery script:[ :script |
script << html jQuery ajax
callback:[ [ self setupCashCartNominativeFor: aName ] “ it can generate error “
on: Error do:[ self requestContext respond:[ :r | ???? " ] ]];

onError:( script <<( script jQuery: #genericErrorDialogId ) dialog open );  
onSuccess:( script << (script jQuery: #idContentView) load html:[:h| self renderContentViewOn: h ])]);

with:[ html div class: class;
with:[ html paragraph: aName greaseString]]

Forget something !?

Some considerations ?

Thanks,

Dario

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

Re: Callback onError: management

Esteban A. Maringolo
Ciao Dario,

You must force the return of an HTTP error response.

on: Error do:[  self requestContext respond:[ :r | r internalError respond ] ]

Regards!

Esteban A. Maringolo

On Thu, Jul 9, 2020 at 12:41 PM Dario Romano Trussardi
<[hidden email]> wrote:

>
> Ciao,
>
> i development with Seaside 3.3 into Pharo 703.
>
> I have an anchor with specific ajax callback:   block.
> Now I’m interested to rendering different data if the callback code erase some error or not.
> I do some test with this code but the onError: script data is always rendering.
>
>
> renderSubTableAnchorFor: aName class: class on: html
>
> html anchor
> onClick:( html jQuery script:[ :script |
> script << html jQuery ajax
> callback:[ [ self setupCashCartNominativeFor: aName ] “ it can generate error “
> on: Error do:[ self requestContext respond:[ :r | “ ???? " ] ]];
>
> onError:( script <<( script jQuery: #genericErrorDialogId ) dialog open );
> onSuccess:( script << (script jQuery: #idContentView) load html:[:h| self renderContentViewOn: h ])]);
>
> with:[ html div class: class;
> with:[ html paragraph: aName greaseString]]
>
>
> Forget something !?
>
> Some considerations ?
>
> Thanks,
>
> Dario
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Callback onError: management

Esteban A. Maringolo
Dario,

Sorry, in my previous email I didn't notice the onSuccess: wasn't sent
to the right object

html anchor
   onClick: (
    (html jQuery ajax) callback: [
      [ self setupCashCartNominativeFor: aName ] on: Error do: [ self
requestContext respond: [ :r | r internalError respond ]
    ];
    onError: ( script <<( script jQuery: #genericErrorDialogId ) dialog open );
    onSuccess: ( script << (script jQuery: #idContentView) load
html:[:h| self renderContentViewOn: h]));
  with:[ html div class: class; with:[ html paragraph: aName greaseString]]

As as a side note sometimes dealing with that kind of handling my be
tricky, so instead of performing an ajax action callback, check the
result and then perform another ajax call for the load, you can simply
have a "script:" callback, this will execute the block in the server
and then you can do everything in a single roundtrip, this has also
the convenience of having a "shorter" (in terms of code) click
handler, since it only has the call to the script callback URL.

E.g.:
html anchor
 onClick: (html jQuery ajax script:[ :script |
  [
   self setupCashCartNominativeFor: aName.
  (script << (script jQuery: #idContentView)) replaceWith: [:h| self
renderContentViewOn: h ]
  ] on: Error do: [:ex | script << (( script jQuery:
#genericErrorDialogId ) dialog open) ]
 ]);

I don't find this isn't to the best way to work, at least
conceptually, since it will inject a <script> tag in your code, but
sometimes it is too complex to do all the handling or you have to
handle everything within an error handler to return #internalError,
etc. But I admit I use it extensively in some cases.

I played with having a handledAjax: method on JQAjax, that basically
wraps the original callback within an error handler that simply
returns an 500 Internal Error response if the callback throws an
error.

Regards!

Esteban A. Maringolo

On Thu, Jul 9, 2020 at 12:55 PM Esteban Maringolo <[hidden email]> wrote:

>
> Ciao Dario,
>
> You must force the return of an HTTP error response.
>
> on: Error do:[  self requestContext respond:[ :r | r internalError respond ] ]
>
> Regards!
>
> Esteban A. Maringolo
>
> On Thu, Jul 9, 2020 at 12:41 PM Dario Romano Trussardi
> <[hidden email]> wrote:
> >
> > Ciao,
> >
> > i development with Seaside 3.3 into Pharo 703.
> >
> > I have an anchor with specific ajax callback:   block.
> > Now I’m interested to rendering different data if the callback code erase some error or not.
> > I do some test with this code but the onError: script data is always rendering.
> >
> >
> > renderSubTableAnchorFor: aName class: class on: html
> >
> > html anchor
> > onClick:( html jQuery script:[ :script |
> > script << html jQuery ajax
> > callback:[ [ self setupCashCartNominativeFor: aName ] “ it can generate error “
> > on: Error do:[ self requestContext respond:[ :r | “ ???? " ] ]];
> >
> > onError:( script <<( script jQuery: #genericErrorDialogId ) dialog open );
> > onSuccess:( script << (script jQuery: #idContentView) load html:[:h| self renderContentViewOn: h ])]);
> >
> > with:[ html div class: class;
> > with:[ html paragraph: aName greaseString]]
> >
> >
> > Forget something !?
> >
> > Some considerations ?
> >
> > Thanks,
> >
> > Dario
> > _______________________________________________
> > seaside mailing list
> > [hidden email]
> > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Callback onError: management

Trussardi Dario Romano
Ciao,



Sorry, in my previous email I didn't notice the onSuccess: wasn't sent
to the right object

html anchor
  onClick: (
   (html jQuery ajax) callback: [
     [ self setupCashCartNominativeFor: aName ] on: Error do: [ self
requestContext respond: [ :r | r internalError respond ]
   ];
   onError: ( script <<( script jQuery: #genericErrorDialogId ) dialog open );
   onSuccess: ( script << (script jQuery: #idContentView) load
html:[:h| self renderContentViewOn: h]));
 with:[ html div class: class; with:[ html paragraph: aName greaseString]]

following the above code I deduced the following code:

html anchor
onClick: ( html jQuery ajax script:[ :script |
script << html jQuery ajax callback:[ 
[ self setupCashCartNominativeFor: aName ]
on: Error do:[ self requestContext respond:[ :r | r internalError respond ]]];

onError: ( script  << (  script jQuery: #genericErrorDialogId ) dialog open);
onSuccess:( script << (script jQuery: #idContentView) load html:[:h| self renderContentViewOn: h ])]);

with:[ html div class: class; with:[ html paragraph: aName greaseString]]

***
With this code the onError : (  script jQuery: #genericErrorDialogId ) dialog open)
is open at any click even if the  [ self setupCashCartNominativeFor: aName ] don’t signal error.

Thanks,

Dario

P.S. In the method self setupCashCartNominativeFor: aName

when needed I signal error with a simple code :   Error signal: ‘error' 


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

Re: Callback onError: management

Trussardi Dario Romano
Ciao,

i do some test but i have not solved the problem.

Now i do some test adding some code to WAWelcome … application  to check everything again and maybe share the problem...

With the last code reporting I have defined the following behaviors:

POINT A) When I generate the  error in the callback method, the system enters in the relative block

html jQuery ajax callback:[ [ self setupCashCartNominativeFor: aName ]
  on: Error do:[ self requestContext respond:[ :r | r internalError respond ]]];

POINT B)  The code:

 onError: ( script  << (  script jQuery: #genericErrorDialogId ) dialog open);
it is always activated even if no error is generated
as if the ajax request always returned an error….


Thanks for considerations.
Dario

Ciao,



Sorry, in my previous email I didn't notice the onSuccess: wasn't sent
to the right object

html anchor
  onClick: (
   (html jQuery ajax) callback: [
     [ self setupCashCartNominativeFor: aName ] on: Error do: [ self
requestContext respond: [ :r | r internalError respond ]
   ];
   onError: ( script <<( script jQuery: #genericErrorDialogId ) dialog open );
   onSuccess: ( script << (script jQuery: #idContentView) load
html:[:h| self renderContentViewOn: h]));
 with:[ html div class: class; with:[ html paragraph: aName greaseString]]

following the above code I deduced the following code:

html anchor
onClick: ( html jQuery ajax script:[ :script |
script << html jQuery ajax callback:[ 
[ self setupCashCartNominativeFor: aName ]

POINT A)
on: Error do:[ self requestContext respond:[ :r | r internalError respond ]]];
onError: ( script  << (  script jQuery: #genericErrorDialogId ) dialog open);
POINT B)
onSuccess:( script << (script jQuery: #idContentView) load html:[:h| self renderContentViewOn: h ])]);

with:[ html div class: class; with:[ html paragraph: aName greaseString]]

***
With this code the onError : (  script jQuery: #genericErrorDialogId ) dialog open)
is open at any click even if the  [ self setupCashCartNominativeFor: aName ] don’t signal error.

Thanks,

Dario

P.S. In the method self setupCashCartNominativeFor: aName

when needed I signal error with a simple code :   Error signal: ‘error' 


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

Re: Callback onError: management

Trussardi Dario Romano
Ciao Joachim,

now everything is working fine,

Considerations, explanations by the way?

Thanks….

Dario

Am 10.07.20 um 17:24 schrieb Dario Romano Trussardi:
Ciao,

i do some test but i have not solved the problem.

Now i do some test adding some code to WAWelcome … application  to check everything again and maybe share the problem...

With the last code reporting I have defined the following behaviors:

POINT A) When I generate the  error in the callback method, the system enters in the relative block

html jQuery ajax callback:[ [ self setupCashCartNominativeFor: aName ]
  on: Error do:[ self requestContext respond:[ :r | r internalError respond ]]];

POINT B)  The code:

 onError: ( script  << (  script jQuery: #genericErrorDialogId ) dialog open);


have you tried omitting "script <<" ?


Joachim



it is always activated even if no error is generated
as if the ajax request always returned an error….


Thanks for considerations.
Dario

Ciao,



Sorry, in my previous email I didn't notice the onSuccess: wasn't sent
to the right object

html anchor
  onClick: (
   (html jQuery ajax) callback: [
     [ self setupCashCartNominativeFor: aName ] on: Error do: [ self
requestContext respond: [ :r | r internalError respond ]
   ];
   onError: ( script <<( script jQuery: #genericErrorDialogId ) dialog open );
   onSuccess: ( script << (script jQuery: #idContentView) load
html:[:h| self renderContentViewOn: h]));
 with:[ html div class: class; with:[ html paragraph: aName greaseString]]

following the above code I deduced the following code:

html anchor
onClick: ( html jQuery ajax script:[ :script |
script << html jQuery ajax callback:[ 
[ self setupCashCartNominativeFor: aName ]

POINT A)
on: Error do:[ self requestContext respond:[ :r | r internalError respond ]]];
onError: ( script  << (  script jQuery: #genericErrorDialogId ) dialog open);
POINT B)
onSuccess:( script << (script jQuery: #idContentView) load html:[:h| self renderContentViewOn: h ])]);

with:[ html div class: class; with:[ html paragraph: aName greaseString]]
***
With this code the onError : (  script jQuery: #genericErrorDialogId ) dialog open)
is open at any click even if the  [ self setupCashCartNominativeFor: aName ] don’t signal error.
Thanks,
Dario

P.S. In the method self setupCashCartNominativeFor: aName
when needed I signal error with a simple code :   Error signal: ‘error' 


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


-- 
-----------------------------------------------------------------------
Objektfabrik Joachim Tuchel          [hidden email]
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://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Callback onError: management

Esteban A. Maringolo
In reply to this post by Trussardi Dario Romano
Hi Dario,

In both of my replies I typed the code without checking it other than
visually with the Gmail editor that doesn't support tabs...

So here I attach a component that does what you need, which I
effectively tested. :-)
So file it in, and then include it in your application or register it
as application as follows:

(WAAdmin register: WAApplication at: 'dario') ifNotNil: [ :app |
WAAdmin configureNewApplication: app.
app preferenceAt: #rootClass put: WADarioComponent ].

Regards!

Esteban A. Maringolo

On Fri, Jul 10, 2020 at 12:25 PM Dario Romano Trussardi
<[hidden email]> wrote:

>
> Ciao,
>
> i do some test but i have not solved the problem.
>
> Now i do some test adding some code to WAWelcome … application  to check everything again and maybe share the problem...
>
> With the last code reporting I have defined the following behaviors:
>
> POINT A) When I generate the  error in the callback method, the system enters in the relative block
>
> html jQuery ajax callback:[ [ self setupCashCartNominativeFor: aName ]
>   on: Error do:[ self requestContext respond:[ :r | r internalError respond ]]];
>
> POINT B)  The code:
>
>  onError: ( script  << (  script jQuery: #genericErrorDialogId ) dialog open);
> it is always activated even if no error is generated
> as if the ajax request always returned an error….
>
>
> Thanks for considerations.
> Dario
>
> Ciao,
>
>
>
> Sorry, in my previous email I didn't notice the onSuccess: wasn't sent
> to the right object
>
> html anchor
>   onClick: (
>    (html jQuery ajax) callback: [
>      [ self setupCashCartNominativeFor: aName ] on: Error do: [ self
> requestContext respond: [ :r | r internalError respond ]
>    ];
>    onError: ( script <<( script jQuery: #genericErrorDialogId ) dialog open );
>    onSuccess: ( script << (script jQuery: #idContentView) load
> html:[:h| self renderContentViewOn: h]));
>  with:[ html div class: class; with:[ html paragraph: aName greaseString]]
>
>
> following the above code I deduced the following code:
>
> html anchor
> onClick: ( html jQuery ajax script:[ :script |
> script << html jQuery ajax callback:[
> [ self setupCashCartNominativeFor: aName ]
>
>
> POINT A)
>
> on: Error do:[ self requestContext respond:[ :r | r internalError respond ]]];
>
> onError: ( script  << (  script jQuery: #genericErrorDialogId ) dialog open);
>
> POINT B)
>
> onSuccess:( script << (script jQuery: #idContentView) load html:[:h| self renderContentViewOn: h ])]);
>
> with:[ html div class: class; with:[ html paragraph: aName greaseString]]
>
> ***
> With this code the onError : (  script jQuery: #genericErrorDialogId ) dialog open)
> is open at any click even if the  [ self setupCashCartNominativeFor: aName ] don’t signal error.
>
> Thanks,
>
> Dario
>
> P.S. In the method self setupCashCartNominativeFor: aName
>
> when needed I signal error with a simple code :   Error signal: ‘error'
>
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

WADarioComponent.st (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Callback onError: management

Trussardi Dario Romano
Ciao Esteban,

        very well.

        Thanks,
               
                Dario

>
> Hi Dario,
>
> In both of my replies I typed the code without checking it other than
> visually with the Gmail editor that doesn't support tabs...
>
> So here I attach a component that does what you need, which I
> effectively tested. :-)
> So file it in, and then include it in your application or register it
> as application as follows:
>
> (WAAdmin register: WAApplication at: 'dario') ifNotNil: [ :app |
> WAAdmin configureNewApplication: app.
> app preferenceAt: #rootClass put: WADarioComponent ].

        It only need the adding of the JQuery Library.  
       

>
> Regards!
>
> Esteban A. Maringolo
>
> On Fri, Jul 10, 2020 at 12:25 PM Dario Romano Trussardi
> <[hidden email]> wrote:
>>
>> Ciao,
>>
>> i do some test but i have not solved the problem.
>>
>> Now i do some test adding some code to WAWelcome … application  to check everything again and maybe share the problem...
>>
>> With the last code reporting I have defined the following behaviors:
>>
>> POINT A) When I generate the  error in the callback method, the system enters in the relative block
>>
>> html jQuery ajax callback:[ [ self setupCashCartNominativeFor: aName ]
>>  on: Error do:[ self requestContext respond:[ :r | r internalError respond ]]];
>>
>> POINT B)  The code:
>>
>> onError: ( script  << (  script jQuery: #genericErrorDialogId ) dialog open);
>> it is always activated even if no error is generated
>> as if the ajax request always returned an error….
>>
>>
>> Thanks for considerations.
>> Dario
>>
>> Ciao,
>>
>>
>>
>> Sorry, in my previous email I didn't notice the onSuccess: wasn't sent
>> to the right object
>>
>> html anchor
>>  onClick: (
>>   (html jQuery ajax) callback: [
>>     [ self setupCashCartNominativeFor: aName ] on: Error do: [ self
>> requestContext respond: [ :r | r internalError respond ]
>>   ];
>>   onError: ( script <<( script jQuery: #genericErrorDialogId ) dialog open );
>>   onSuccess: ( script << (script jQuery: #idContentView) load
>> html:[:h| self renderContentViewOn: h]));
>> with:[ html div class: class; with:[ html paragraph: aName greaseString]]
>>
>>
>> following the above code I deduced the following code:
>>
>> html anchor
>> onClick: ( html jQuery ajax script:[ :script |
>> script << html jQuery ajax callback:[
>> [ self setupCashCartNominativeFor: aName ]
>>
>>
>> POINT A)
>>
>> on: Error do:[ self requestContext respond:[ :r | r internalError respond ]]];
>>
>> onError: ( script  << (  script jQuery: #genericErrorDialogId ) dialog open);
>>
>> POINT B)
>>
>> onSuccess:( script << (script jQuery: #idContentView) load html:[:h| self renderContentViewOn: h ])]);
>>
>> with:[ html div class: class; with:[ html paragraph: aName greaseString]]
>>
>> ***
>> With this code the onError : (  script jQuery: #genericErrorDialogId ) dialog open)
>> is open at any click even if the  [ self setupCashCartNominativeFor: aName ] don’t signal error.
>>
>> Thanks,
>>
>> Dario
>>
>> P.S. In the method self setupCashCartNominativeFor: aName
>>
>> when needed I signal error with a simple code :   Error signal: ‘error'
>>
>>
>> _______________________________________________
>> seaside mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> <WADarioComponent.st>_______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside