GWT is a powerful framework, and it is certainly possible to create a Synchronous XHR with it, but it is such an epically bad idea that 1) it is not available by default, 2) everyone who is familiar with GWT development is warning you against doing it, and 3) we sure aren't going to go through the effort to write the code to do it for you.
As for the code clarity, argument, my async code is quite clear and maintainable. The request type really has nothing to do with how clear or readable your code is. That said, if you really want to create synchronous requests then you'll need to look at the request builder code to see how the Async requests are done, then do a google search on javascript XMLHTTPRequest and see how to make the request synchronous. then extend request builder (or create a parallel class) to do that. But remember this is the programming equivalent of designing a wall heater with the express design decision to start the consumers house on fire. It really is that bad! -jason On Aug 27, 2008, at 2:55 AM, ping2ravi wrote: > > Jason, > I think any framework should give all options to developer to design > his own way, and poor design and good design are all relative terms, > so cant do generalization of that. > But thanks for sharing your thoughts. > > cheers, > Ravi :) > > On Aug 26, 7:14 pm, Jason Essington <[EMAIL PROTECTED]> wrote: >> nope, again, this use case shows a poor decision of using a >> synchronous request. In fact I'm not aware of a single good use of a >> synchronous request in a browser. >> >> I do this very thing using Async RPCs. I start by opening a modal >> dialog. the user can type his credentials into the "login" dialog, >> and >> submit them. >> The submit button is disabled as soon as it is pressed, but the >> dialog >> is not dismissed preventing any clicking anywhere else in the >> application. >> Once the RPC returns indicating that the user has successfully >> authenticated, the dialog is dismissed, and any original RPC (that >> triggered the session timeout notification) is resent. >> >> There are glass panels Modal Dialogs and other techniques that >> prevent >> the user from poking about in the application that do not lock up the >> browser, and any of those techniques should be used long before >> attempting to hack in a Synchronous request. >> >> There is no case where you as a programmer should cause your user's >> UI >> to completely lock up. It is fine to disable bits, but synchronous >> requests don't play nice, they completely lock up the browser, in >> some >> cases, not allowing the user to switch tabs, or browse other pages, >> or >> even close the browser. Users don't like that, and as a result, will >> equate the behavior with poor programming on your part. So, just >> don't >> do it. >> >> -jason >> >> On Aug 26, 2008, at 11:53 AM,ping2raviwrote: >> >> >> >>> yes i do have have workaround for this, but was just wondering if i >>> can use any of GWT feature. >>> Also i read in GWT FAQ, GWT do not support Synchronous calls and in >>> future they are not planning to have it(they have some theory). So i >>> guess need to implement my own workaround. >>> http://code.google.com/support/bin/answer.py? >>> answer=55195&topic=10210 >> >>> But guys just a question of thought, Don't you think having a >>> synchronous call feature will be added advantage. >> >>> Lets say u build a application and u have something like if user >>> logged out of application because of idle session then when user try >>> to do anything on application. instead of forwarding him to some >>> user >>> login page , we just popup a login/password panel thing. And usually >>> on click we will call the login on server and close the dialogue >>> box(againw e can keep it open and in onSuccess function we can close >>> it, but for me not a good idea) >>> And as the call is asynchrnous so once we call the Login on server, >>> user is allowed to do other click in application(before he actually >>> login to server) and he will again see that u r not logged in. >>> Its just a small example. >> >>> But i think having synchronous call will be good thing. >> >>> Thanks for reading >>> Ravi. >> >>> On Aug 26, 5:03 pm, "Pavel Byles" <[EMAIL PROTECTED]> wrote: >>>> can't you just do: >>>> doTaskCallBack { >>>> onResponse(...) { >>>> userService.doSynchronousTask(...); >>>> } >> >>>> } >> >>>> Wouldn't that just give the synchronous effect? >> >>>> On Mon, Aug 25, 2008 at 6:24 AM,ping2ravi<[EMAIL PROTECTED]> >>>> wrote: >> >>>>> Hi All, >> >>>>> Does any one know how to make Synchronous calls using GWT. >>>>> Currently i am using GWT to build services, creating files like >> >>>>> com.app.client.MyService.java >>>>> //One function in this interface >>>>> doMyTask(ParamTpye myparams) throws ClientException; >> >>>>> com.app.client.MyServiceAsync.java >>>>> //One function in this interface >>>>> doMyTask(ParamTpye myparams,AsyncCallback callback) throws >>>>> ClientException; >> >>>>> com.app.server.MyServiceImpl.java >>>>> //One function in this class >>>>> doMyTask(ParamTpye myparams) throws ClientException; >> >>>>> now i create the service and call >>>>> MyServiceAsync userService = (MyServiceAsync) >>>>> GWT.create(MyService.class); >>>>> ServiceDefTarget endpoint = (ServiceDefTarget) userService; >>>>> String moduleRelativeURL = GWT.getModuleBaseURL() + >>>>> "MyService"; >>>>> endpoint.setServiceEntryPoint(moduleRelativeURL); >>>>> userService.doMyTask(MyParams,CallBackObject); >> >>>>> This piece of code is working fine as a ASYNCHRONOUS call. >> >>>>> Then i tried making is synchronous call using following code(i >>>>> don't >>>>> know if its valid or not) >>>>> instead of using MyServiceAsync i am using MyService >> >>>>> MyService userService = (MyService) >>>>> GWT.create(MyService.class); >>>>> ServiceDefTarget endpoint = (ServiceDefTarget) userService; >>>>> String moduleRelativeURL = GWT.getModuleBaseURL() + >>>>> "MyService"; >>>>> endpoint.setServiceEntryPoint(moduleRelativeURL); >>>>> userService.doMyTask(MyParams); >> >>>>> But call to doMyTask throw following exception. >>>>> java.lang.ClassCastException in MyService_Proxy. >> >>>>> So i guess this is not the way to make synchronous call in GWT >>>>> Can any one point me how to do that. Or its not possible at all in >>>>> GWT. >> >>>>> Thanks in advance., >>>>> Ravi. > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
