Bonjour voilà j'ai un petit souci j'aimerais pouvoir récupérer les valeurs de mes interventions issues de l'url suivante:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
http://localhost:8080/NoteTonSTA/rest/interventions/2
avec comme ressources json:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
{"interventions": [{"id" : "2","subject":"android","begin":"12 Janvier 2012","end":"12 Janvier 2012"}]},{"id" : "3","subject":"linux","begin":"13 janvier 2012","end":"13 janvier 2012"}]},{"id" : "4","subject":"cisco","begin":"12 Janvier 2012","end":"12 Janvier 2012"}]}
Le problème avec mon code c'est qu'il ne me récupère que les premiers id (les premières interventions) en fonction des différentes pages. J'aimerais savoir comment récupérer tous les id sachant que quand j'ai plusieurs id, la fonction suivante puisse me retourner toutes les interventions (qu'il y en ai une ou plusieurs):


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package com.supinfo.notetonsta.web;
 
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
 
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
 
import android.util.Log;
 
public class WebIntervention {
 
	JSONArray jsonArray;//contiendra la liste de tous les campus
	JSONObject jsonObject;	
	private List<String>listInterventions;
	String result;
 
	public WebIntervention() {
 
	}
 
	public List<String>getAllInterventions(long idCampus){
 
		List<String>interventionsByIdCampus = new ArrayList<String>();
 
		try {
			//connexion a la ressource
			HttpClient httpClient = new DefaultHttpClient();
			HttpGet httpGet = new HttpGet();
 
			httpGet.setURI(new URI("http://10.0.2.2:8080/NoteTonSTA/rest/interventions/"+idCampus));
			httpGet.setHeader("Content-Type","application/json");//utilisation json et non xml
 
			HttpResponse httpResponse = httpClient.execute(httpGet);
			result = EntityUtils.toString(httpResponse.getEntity());	
 
		} catch (Exception e) {
			Log.e("HTTPClient", e.getMessage(), e);
		}
 
		try {
			jsonObject = new JSONObject(result);
			jsonArray = jsonObject.getJSONArray("interventions");
 
			if (jsonObject == null) {//voir plus tard comment gérer cette exception
				interventionsByIdCampus.add("Pas d'intervention pour le Campus choisi");
			} else {
 
			}
 
		} catch (Exception e) {
			Log.e(getClass().getName(), e.getMessage(), e);
		}
 
		//récupération des interventions en fonction des campus:
		for (int i = 0; i < jsonArray.length(); i++) {
			try {
				JSONObject object = jsonArray.getJSONObject(i);
 
				String subject = object.getString("subject");
				String beginDate = object.getString("begin");
				String enDate = object.getString("end");
				//pas de status a chopper malheureusement :(
 
				String informations = "Intervention: "+ subject + "\nDebut: " + beginDate + "\nFin:" + enDate;
				//String informations = subject+beginDate;
 
				interventionsByIdCampus.add(informations);
 
			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
 
		}
 
		return interventionsByIdCampus;
 
	}
 
}
Je vous remercie d'avance