Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 69 Rev 91
Line 2... Line 2...
2
 
2
 
3
import org.tela_botanica.client.RegistreId;
3
import org.tela_botanica.client.RegistreId;
Line 4... Line 4...
4
import org.tela_botanica.client.interfaces.Rafraichissable;
4
import org.tela_botanica.client.interfaces.Rafraichissable;
-
 
5
 
5
 
6
import com.extjs.gxt.ui.client.Registry;
6
import com.extjs.gxt.ui.client.Registry;
7
import com.google.gwt.core.client.GWT;
7
import com.google.gwt.http.client.Request;
8
import com.google.gwt.http.client.Request;
8
import com.google.gwt.http.client.RequestBuilder;
9
import com.google.gwt.http.client.RequestBuilder;
9
import com.google.gwt.http.client.RequestCallback;
10
import com.google.gwt.http.client.RequestCallback;
10
import com.google.gwt.http.client.RequestException;
11
import com.google.gwt.http.client.RequestException;
-
 
12
import com.google.gwt.http.client.Response;
11
import com.google.gwt.http.client.Response;
13
import com.google.gwt.json.client.JSONArray;
-
 
14
import com.google.gwt.json.client.JSONObject;
12
import com.google.gwt.json.client.JSONArray;
15
import com.google.gwt.json.client.JSONParser;
Line 13... Line 16...
13
import com.google.gwt.json.client.JSONParser;
16
import com.google.gwt.json.client.JSONString;
Line 14... Line 17...
14
import com.google.gwt.json.client.JSONValue;
17
import com.google.gwt.json.client.JSONValue;
Line 15... Line 18...
15
 
18
 
16
public class ValeurListeAsyncDao {
19
public class ValeurListeAsyncDao {
17
	
20
	
Line 18... Line 21...
18
	private Rafraichissable rafraichissement = null;
21
	private Rafraichissable rafraichissement = null;
19
	
22
	
20
	public ValeurListeAsyncDao(Rafraichissable r) {
23
	public ValeurListeAsyncDao(Rafraichissable r) {
-
 
24
		rafraichissement = r;
21
		rafraichissement = r;
25
	}
22
	}
-
 
-
 
26
	
23
	
27
	public void obtenirListe(Integer cle) {
24
	public void obtenirListe(String cle) {
28
		// Demande de toutes les structures
Line 25... Line 29...
25
    	// Demande de toutes les structures
29
    	String url = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl();
26
    	String url = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl();
30
    	url = url+"CoelValeurListe/id/"+cle.toString();
Line 27... Line 31...
27
		RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, url+"CoelListe/id/"+cle);
31
		RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, url);
Line 28... Line 32...
28
 
32
		GWT.log(url, null);
-
 
33
		try {
29
		try {
34
			rb.sendRequest(null, new RequestCallback() {
Line 30... Line 35...
30
			rb.sendRequest(null, new RequestCallback() {
35
 
31
 
36
				public void onError(Request request, Throwable exception) {
-
 
37
					// TODO Auto-generated method stub
32
				public void onError(Request request, Throwable exception) {
38
 
-
 
39
				}
-
 
40
 
33
					// TODO Auto-generated method stub
41
				public void onResponseReceived(Request request, Response response) {
34
 
42
					
35
				}
43
					final JSONValue responseValue = JSONParser.parse(response.getText());
36
 
44
 
-
 
45
					// Si la requête est un succès, reception d'un tableau
-
 
46
					if (responseValue.isObject() != null) {
-
 
47
						try {
37
				public void onResponseReceived(Request request, Response response) {
48
							final JSONObject reponse = responseValue.isObject();
Line 38... Line 49...
38
					final JSONValue responseValue = JSONParser.parse(response.getText());
49
							JSONString listeId = reponse.get("id").isString();
39
 
50
							JSONArray listeValeurs = reponse.get("valeurs").isArray();
40
					// Si la requête est un succès, reception d'un tableau
51
							// Transformation du tableau JSON réponse en Liste