views:

34

answers:

2

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)

+2  A: 

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.

Igor Klimer
I'm using GXT FormPanel. And i'm not sure if the addSubmitCompleteHandler is exactly what i need. I'll try to explain it better in my post.
cupakob
Ah, if it's GXT, then I can't help :) But let me get this straight - you are submitting some data to the server, and *before* you submit it, you want to *first* get some data from the database (on the same server, I presume) and then submit? Why not submit the data and do get stuff from the DB on the server-side?
Igor Klimer
Right! Before to submit i need some data from the DB (the same server) and this data, which i get from the DB will be also submited. I can't make it on the server side, because i need to display massages (for the user) in frontend. But the "BeforSubit" ist also wrong :( I think, i have another idea and if it works, i'll post the solution here.
cupakob
Could you update your question with a detailed description of your problem? Either something is really wrong here or we don't have the whole picture. What message are you displaying, does it need the actual data or just some sort of confirmation from the DB? And if you don't modify the data got from the DB, why sent it back again (with the additional risk of it being tampered with client-side), etc.
Igor Klimer
A: 

the solution of the problem is to add a submit listener (Events.Submit), wich is the same as addSubmitCompleteHandler for the gwt form panel.

cupakob