Re: Getting continued feedback on the state of a RPC call
I think its an issue of threading on server side. This is how it works for me !!! By clicking on button Get Service message. Let me know if it works for you. +Bakul Kumar+ //Client side code : public class POC implements EntryPoint { Label lblMessage; Timer timer = new Timer() { public void run() { StockServiceAsync service = new StockServiceRPC() .getStockServiceAsync(); service.getMessage(new AsyncCallbackString(){ public void onSuccess(String result) { lblMessage.setText(Comp Message : + result); } public void onFailure(Throwable caught) { Window.alert(Call Failed on Server); } }); }; }; public void onModuleLoad() { Image img = new Image( http://code.google.com/webtoolkit/logo-185x175.png;); Button button = new Button(Click me); button.addStyleName(pc-template-btn); img.getElement().setId(pc-template-img); VerticalPanel vPanel = new VerticalPanel(); vPanel.setWidth(100%); vPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); vPanel.add(img); vPanel.add(button); Button serviceButton = new Button(Get Service Message); vPanel.add(serviceButton); serviceButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { timer.scheduleRepeating(1000); StockServiceAsync service = new StockServiceRPC() .getStockServiceAsync(); //This one do the job of setting the entry point for RPC call service.longComputation(new AsyncCallbackString() { public void onSuccess(String result) { timer.cancel(); Window.alert(Long Comp Message : + result); } public void onFailure(Throwable caught) { timer.cancel(); Window.alert(Call Failed on Server); } }); } }); lblMessage = new Label(Message); vPanel.add(lblMessage); // Add image and button to the RootPanel RootPanel.get().add(vPanel); // Create the dialog box final DialogBox dialogBox = new DialogBox(); dialogBox.setText(Welcome to GWT!); dialogBox.setAnimationEnabled(true); Button closeButton = new Button(close); VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.setWidth(100%); dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); dialogVPanel.add(closeButton); closeButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { dialogBox.hide(); } }); // Set the contents of the Widget dialogBox.setWidget(dialogVPanel); button.addClickListener(new ClickListener() { public void onClick(Widget sender) { dialogBox.center(); dialogBox.show(); } }); } } Server side code public class StockServiceImpl extends RemoteServiceServlet implements StockService { private static final long serialVersionUID = 1L; String message; public StockPrice getPrices(String[] symbols) { return new StockPrice(LEH, 0.0); } public String longComputation(){ for(long i = 0; i 10; i++){ message = Iteration # + i; try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } } return BK Rocks !!!, Calculation Completes; } public String getMessage(){ final StringBuffer myMessage = new
Getting continued feedback on the state of a RPC call
Hi all, I have a GWT application which uses a remote service that does some complex, and potentially long work. However, I don't want to hold the user unaware of the status of their request for too long. So I would like a way for the client app to receive frequent information on the service status, which would be posted to the UI in real time. I've unsuccessfully tried the following way: The client makes a call to the remote service, which starts doing its job. The service itself, in turn, modifies some state variable during the course of its computation. So I created a client-side Timer which, every second, polls another remote service that simply returns this state variable. This timer is started right before the main service is called, and is halted after the service returns. Being these calls asynchronous, this method didn't work. All scheduled Timer calls returned after the main service altogether. I know it might be a dumb question, but it would really be helpful for me to be able to provide the user with continued feedback on the state of the service they called. Thank You --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to Google-Web-Toolkit@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Getting continued feedback on the state of a RPC call
Hi, Event I am a newbie in java and GWt, though how about partitioning your long job, as in... e.g. For a http call which needs to access names say 100,000 in number. I might actually partition this call in say 26 calls with each call querying names starting with each of the 26 alphabets... and on the callback of the first function I might update the user and make the second call and so on. Actually do a chaining... :) Thats just a guess... may be that I might be totally wrong on this... :) Cheers, Amit Dhingra On Tue, Sep 23, 2008 at 3:19 PM, Palietta [EMAIL PROTECTED] wrote: Hi all, I have a GWT application which uses a remote service that does some complex, and potentially long work. However, I don't want to hold the user unaware of the status of their request for too long. So I would like a way for the client app to receive frequent information on the service status, which would be posted to the UI in real time. I've unsuccessfully tried the following way: The client makes a call to the remote service, which starts doing its job. The service itself, in turn, modifies some state variable during the course of its computation. So I created a client-side Timer which, every second, polls another remote service that simply returns this state variable. This timer is started right before the main service is called, and is halted after the service returns. Being these calls asynchronous, this method didn't work. All scheduled Timer calls returned after the main service altogether. I know it might be a dumb question, but it would really be helpful for me to be able to provide the user with continued feedback on the state of the service they called. Thank You -- Warm Regards, Amit Dhingra --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to Google-Web-Toolkit@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Getting continued feedback on the state of a RPC call
Hello, Palietta schrieb: So I created a client-side Timer which, every second, polls another remote service that simply returns this state variable. This timer is started right before the main service is called, and is halted after the service returns. Being these calls asynchronous, this method didn't work. All scheduled Timer calls returned after the main service altogether. I know it might be a dumb question, but it would really be helpful for me to be able to provide the user with continued feedback on the state of the service they called. Can you provide some source how you call the long running task and create the timer? I have some ideas why this fails, but it's only guessing without knowing more. Independent from that you might google for Comet GWT. This might be a solution for you as well. Regards, Lothar --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to Google-Web-Toolkit@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Getting continued feedback on the state of a RPC call
Palietta schrieb: obviously, in the code sample, the AsyncCallback object returned by doLengthComputation() is not an AsyncCallbackString ... and I must have forgotten a closing bracket in the poll() function... still, any ideas? Why are you calling timer.run()? The comment doesn't fit to that because the start of the timer already happens at the beginning with t.scheduleRepeating(1000) Is there some kind of synchronization happening on server- side, blocking the retrieval of the status while the computation is still in progress? Maybe some printlns on the server-side help to find out. In addition to that you might check inside the timer if another status-request is still active to avoid the flooding of requests. Regards, Lothar --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to Google-Web-Toolkit@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Getting continued feedback on the state of a RPC call
May be you would like to try polling a servlet using HttpRequest class for your timer calls. Lets know if you succeed. cheers, On Sep 23, 4:09 pm, Amit Dhingra [EMAIL PROTECTED] wrote: Hi, Event I am a newbie in java and GWt, though how about partitioning your long job, as in... e.g. For a http call which needs to access names say 100,000 in number. I might actually partition this call in say 26 calls with each call querying names starting with each of the 26 alphabets... and on the callback of the first function I might update the user and make the second call and so on. Actually do a chaining... :) Thats just a guess... may be that I might be totally wrong on this... :) Cheers, Amit Dhingra On Tue, Sep 23, 2008 at 3:19 PM, Palietta [EMAIL PROTECTED] wrote: Hi all, I have a GWT application which uses a remote service that does some complex, and potentially long work. However, I don't want to hold the user unaware of the status of their request for too long. So I would like a way for the client app to receive frequent information on the service status, which would be posted to the UI in real time. I've unsuccessfully tried the following way: The client makes a call to the remote service, which starts doing its job. The service itself, in turn, modifies some state variable during the course of its computation. So I created a client-side Timer which, every second, polls another remote service that simply returns this state variable. This timer is started right before the main service is called, and is halted after the service returns. Being these calls asynchronous, this method didn't work. All scheduled Timer calls returned after the main service altogether. I know it might be a dumb question, but it would really be helpful for me to be able to provide the user with continued feedback on the state of the service they called. Thank You -- Warm Regards, Amit Dhingra --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to Google-Web-Toolkit@googlegroups.com 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 -~--~~~~--~~--~--~---