![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 6 of 6 total |
![]() |
Thu, Sep 24 2015 2:08 PM | Permanent Link |
squiffy Telemix Ltd. | I have a question that is related to my previous one here : http://www.elevatesoft.com/forums?action=view&category=ewb&id=ewb_general&msg=7275&page=1
Most of my AJAX requests have a common block of code in the onComplete callback event (checking for not authenticated, not authorised or just bad response codes from the server). They also have code specific to the form, usually for the good (200) response from the server. So my questions : 1. does the callback need to be a class method with (Request: TServerRequest) parameter rather than just a regular procedure? I assume yes. 2. if yes, can I create a generic class with a method to handle the received data and attach it to the onComplete event of the Server Request in my code? If yes to both, then I have a bug in my code and I shall just work through it. But I wanted to ask in case I'm barking up the wrong tree. |
Thu, Sep 24 2015 2:09 PM | Permanent Link |
squiffy Telemix Ltd. | Ignore me. I hit post instead of cancel - I've already worked it out and found my bug.
And just in case anyone else finds it useful, yes you can. |
Thu, Sep 24 2015 2:15 PM | Permanent Link |
squiffy Telemix Ltd. | Hmm, except it's no good as I can't then process localised "good" messages as I've passed control to another class method.
Suppose the best way is to call a local onComplete method which calls a separate unit's "dealWithErrors" proc. Just thinking out loud ... |
Fri, Sep 25 2015 4:14 AM | Permanent Link |
Matthew Jones | squiffy wrote:
> Just thinking out loud ... I don't know if I understand your situation properly, but why are you creating another class for the completion routine? Why not have it as a member of your form's class? That way the completion routine has the full information about what is happening, and can take appropriate action? For some of my requests to the server, I pass in a parameter that identifies the client's state. The parameter comes back and the completion routine looks at the parameter to determine what it should do next. And of course it can watch for errors etc at the start of processing. -- Matthew Jones |
Fri, Sep 25 2015 4:57 AM | Permanent Link |
squiffy Telemix Ltd. | Hi Matthew,
most of that thread was me thinking out loud. Comes from working in isolation ![]() I have many forms, all of which make server requests for their data. All of them have a block of standard ways of dealing with error codes from the server but custom ways of dealing with success codes. I was trying to create a unit that deals with the error codes to avoid repeating code, and thought that making that code the server request callback would simplify things. But my thinking was flawed - the obvious way to do it is to use the standard onComplete event then from there call the error handling code. Then I can add the custom success code as normal. Just got my thinking in a pickle, that's all ![]() |
Fri, Sep 25 2015 5:21 AM | Permanent Link |
Matthew Jones | squiffy wrote:
> I have many forms, all of which make server requests for their data Me too. Some do handle errors, but my main form also has some routines that are common and so the child forms call the parent with a callback. You can get quite fancy if you want to! -- Matthew Jones |
This web page was last updated on Wednesday, November 29, 2023 at 09:43 PM | Privacy Policy![]() © 2023 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |