How to show Notification/Window when Server is fetching results

Hi,

I am trying to call server which is deployed in FUSE using CXF REST. It will send me reply by querying the DB tables which would take more time (more than 1 min).

I would like to show the message using getWindow().showNotification(“Fetching results…Please wait”); I am displaying this message before the CXF REST call method, but it is not showing the notification message until the results come from server.

I have tried using modal window as well (instead of getWindow().showNotification(“”), but that didn’t help.

Is there any way to show the status message when server is processing huge queries.

I am using below code to call the REST server.

JAXRSClientFactory.create(baseURI, IEmployeeService.class).getRecords(empId);

If the reply from server took more than 2 mins then it is failing with time out exception. Is there any way to set the timeout?

I am using vaadin 6.6.6 version using STS with GWT 2.4 & tomcat 6.

Br,
Sankar

Look at the ProgressIndicator Component of VAADIN. Of course this would imply using Threads.

Thanks for the quick reply. I have seen that. But is there any way to show Window or Message instead of Progress Bar. I may not know how much time server will take.

I would like to send the value to the server and receive XML reply from the server. Meanwhile I would like to show the Window/ Status Message.

Without using Thread, is there any alternative way.

GWT will have that in built. It will execute the first statement first and later it will send the request to server. Am I missing anything here.

Hm, this should work without threading:

  1. add window to main window with “please wait” text and a fancy animated gif
  2. start long task
  3. remove window from main window.

we will have this feature in our application too. if i get some time i will test it :wink:

Edit: my bad - the long task prevents writing the response so there is no way informing the browser to show your dialog. it will not work without threading.

Hi Jan,

I have tried adding thread by referring below site, but it didn’t work. Can you give me sample working code.

https://vaadin.com/book/-/page/components.datefield.html

My requirement is to send string to server and receive object from server using REST call. Before that I would like to show “Please wait …fetching results”. Once I receive reply from server I will close that status message(Window).

Br,
Sankar

Look at the code example of the VAADIN ProgressIndicator.

Just create a ProgressListener Interface with at least two methods: fireTaskStarted() and fireTaskEnded();

Then write your own Window (extend VAADIN Window) and implement this interface.

  • on fireTaskStarted() do application.getMainWindow().addComponent(this);
  • on fireTaskEnded() do getParent().remove(this);

Now you have to give this interface to your backend task which should run in a background thread.

Quick and really dirty example:


final ProgressListener listener = new ProgressWindow(); // This is your Window implementation
new Button("Start).addListener(new ClickListener() {
   public void onClick(Event e)  {
      listener.fireTaskStarted(); // Have to be unthreaded
      new Thread() {
         public void run() {
            try {
                    getService().fetchResults();
            } finally {
                listener.fireTaskEnded(); // Ensure window will disappear
            }
         }
      }.start();
  }
}});

This will automatically popup a window on the begin of the task and close it on the end of the task.

You can give the ProgressListener interface more methods like fireProgressAt(float current, float max) to indicate the progress.
These information can be used by VAADIN ProgressIndicator.

Did you read
this thread
?

You should use a pull or push mechanism between the browser and the server, and a background thread on the server to perform the request and to remove the window.