814 |
aurelien |
1 |
package org.tela_botanica.del.client.services.rest.async;
|
|
|
2 |
|
|
|
3 |
import org.tela_botanica.del.client.modeles.ProtocoleServiceResultat;
|
|
|
4 |
|
|
|
5 |
import com.google.gwt.http.client.Request;
|
|
|
6 |
import com.google.gwt.http.client.RequestCallback;
|
|
|
7 |
import com.google.gwt.http.client.Response;
|
|
|
8 |
import com.google.gwt.json.client.JSONParser;
|
|
|
9 |
import com.google.gwt.user.client.Window;
|
|
|
10 |
|
|
|
11 |
public abstract class ProtocolesCallback implements RequestCallback {
|
|
|
12 |
|
|
|
13 |
public ProtocolesCallback() {
|
|
|
14 |
|
|
|
15 |
}
|
|
|
16 |
|
|
|
17 |
@Override
|
|
|
18 |
public void onResponseReceived(Request request, Response response) {
|
|
|
19 |
ProtocoleServiceResultat protocolesRecus = convertirReponseVersListeProtocoles(response);
|
|
|
20 |
surProtocolesRecus(protocolesRecus);
|
|
|
21 |
}
|
|
|
22 |
|
|
|
23 |
@Override
|
|
|
24 |
public void onError(Request request, Throwable exception) {
|
|
|
25 |
Window.alert(exception.getMessage());
|
|
|
26 |
}
|
|
|
27 |
|
|
|
28 |
public abstract void surProtocolesRecus(ProtocoleServiceResultat protocolesRecus);
|
|
|
29 |
|
|
|
30 |
private ProtocoleServiceResultat convertirReponseVersListeProtocoles(Response reponse) {
|
|
|
31 |
ProtocoleServiceResultat resultat = new ProtocoleServiceResultat(JSONParser.parseStrict(reponse.getText()));
|
|
|
32 |
return resultat;
|
|
|
33 |
}
|
|
|
34 |
|
|
|
35 |
}
|