Subversion Repositories eFlore/Applications.del

Rev

Rev 823 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 823 Rev 939
Line 1... Line 1...
1
package org.tela_botanica.del.client.services.rest.async;
1
package org.tela_botanica.del.client.services.rest.async;
Line 2... Line -...
2
 
-
 
3
import com.google.gwt.http.client.Request;
-
 
4
import com.google.gwt.http.client.RequestCallback;
-
 
5
import com.google.gwt.http.client.Response;
-
 
6
import com.google.gwt.user.client.Window;
-
 
7
 
2
 
8
public abstract class VoteProtocoleCallback implements RequestCallback {
-
 
9
	
-
 
10
	public enum ModeRequete {
-
 
11
		AJOUT, MODIFICATION
-
 
12
	}
-
 
13
	
-
 
14
	protected ModeRequete mode;
-
 
15
		
-
 
16
	public VoteProtocoleCallback(ModeRequete mode) {
-
 
17
		this.mode = mode;
-
 
18
	}
-
 
19
 
-
 
20
	public VoteProtocoleCallback() {
-
 
21
		// TODO Auto-generated constructor stub
-
 
22
	}
-
 
23
	
-
 
24
	public void setMode(ModeRequete mode) {
-
 
25
		this.mode = mode;
-
 
Line 26... Line 3...
26
	}
3
public abstract class VoteProtocoleCallback extends PHPCallback<Void> {
27
 
4
 
28
	@Override
-
 
29
	public void onResponseReceived(Request request, Response response){
-
 
30
		int statusCode = response.getStatusCode();
-
 
31
		int codeAttendu = 500;
-
 
32
		switch (mode) {
-
 
33
			case AJOUT:
-
 
34
				codeAttendu = 201;
-
 
35
				break;
-
 
36
			case MODIFICATION:
-
 
37
				codeAttendu = 200;
5
	@Override
38
				break;
-
 
39
			default:
-
 
40
				codeAttendu = 500;
-
 
41
				break;
-
 
42
		}
-
 
43
		
-
 
44
		if (statusCode == codeAttendu) {
-
 
45
			surRetour(response.getText());
-
 
46
		} else {
-
 
47
			surErreur("Erreur " + statusCode + ": " + response.getText());
6
	public Void parserJSON(String retourService) {
Line 48... Line -...
48
		}
-
 
49
	}
-
 
50
 
-
 
51
	@Override
-
 
52
	public void onError(Request request, Throwable exception) {
-
 
53
		Window.alert(exception.getMessage());
-
 
54
	}
-
 
55
	
7
		return null;