Search code examples
databasegwtsynchronizationgxtformpanel

GWT and notifyAll() (java.lang.Object)


I'm making a call to the database. The result must be used for a subit form. So i want to wait until the result from the DB comes. For that i need a synchronization. My idea was to use the Object.notifyAll() from java.lang, but GWT doesn't support this. Is there any equivalent method in GWT for the notifyAll()?

edit1: I'm using gxt FormPanel to submit the data. I can change the type of the buttonBar, but i think, addSubmitCompleteHandler will not solve my problem.

Here some code snippet:

final Button submit = new Button("Submit");
submit.addListener(Events.OnClick, new Listener<ButtonEvent>() {
    @Override
    public void handleEvent(ButtonEvent be) {
        // 1. Get the data from Database (here i must wait for the response from DB)
        // 2. Submit the form               
    }
);

final FormPanel buttonBar = new FormPanel();
buttonBar.addStyleName("abUploadField");
buttonBar.setHeaderVisible(false);
buttonBar.setBorders(false);
buttonBar.setStyleAttribute("margin", "0px");
buttonBar.setEncoding(FormPanel.Encoding.MULTIPART);
buttonBar.setMethod(FormPanel.Method.POST);
buttonBar.add(file);
buttonBar.add(submit);
buttonBar.setAction("myURL");

edit2: I want to get a sequence ID from the DB (this is the step one in the event handler). This ID will be used for the submit. On submit i'm filling some tabels in the DB with data. The ID will be used to identify, which user started the submit and for this user i want to show dialog with message "Submit successful". I hope, you understand what i mean :) (sorry, my english ist not good)


Solution

  • Like you said, GWT doesn't support Object.notifyAll(). But if you're using FormPanel for submitting your values, you can just addSubmitCompleteHandler and get notified when the results come back. Same thing if you're using RequestBuilder - supply a RequestCallback that will get fired when the response to the request is received.