Subversion Repositories eFlore/Applications.del

Rev

Rev 939 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package org.tela_botanica.del.client.services.rest.async;

import org.tela_botanica.del.client.modeles.ProtocoleServiceResultat;

import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.Response;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.user.client.Window;

public abstract class ProtocolesCallback implements RequestCallback {

        public ProtocolesCallback() {

        }

        @Override
        public void onResponseReceived(Request request, Response response) {
                ProtocoleServiceResultat protocolesRecus = convertirReponseVersListeProtocoles(response);
                surProtocolesRecus(protocolesRecus);
        }

        @Override
        public void onError(Request request, Throwable exception) {
                Window.alert(exception.getMessage());
        }

        public abstract void surProtocolesRecus(ProtocoleServiceResultat protocolesRecus);

        private ProtocoleServiceResultat convertirReponseVersListeProtocoles(Response reponse) {
                ProtocoleServiceResultat resultat = new ProtocoleServiceResultat(JSONParser.parseStrict(reponse.getText()));
                return resultat;
        }

}