Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 121 Rev 133
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;
Line 62... Line 63...
62
						}
63
						}
63
					}
64
					}
64
				}
65
				}
Line 65... Line 66...
65
				
66
				
-
 
67
			}) ;
-
 
68
		} catch (RequestException e) {
-
 
69
			
-
 
70
		}
-
 
71
	}
-
 
72
 
-
 
73
	public void supprimer(final Rafraichissable r, String idUtilisateur, String idStr) {
-
 
74
		// Ajout des paramètres et données à supprimer dans l'URL
-
 
75
		final String url = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl() + 
-
 
76
			"CoelStructureListe/" +
-
 
77
			idUtilisateur + "/" +
-
 
78
			idStr +
-
 
79
			"";
-
 
80
		
-
 
81
		// DELETE n'étant pas disponible comme méthode HTTP, nous utilisons POST avec le paramètre action=DELETE
-
 
82
		RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, url);
-
 
83
		String postDonnees = "action=DELETE";
-
 
84
		
-
 
85
		try {
-
 
86
			rb.sendRequest(postDonnees, new RequestCallback() {
-
 
87
 
-
 
88
				public void onError(Request request, Throwable exception) {
-
 
89
					// TODO Auto-generated method stub
-
 
90
					
-
 
91
				}
-
 
92
 
-
 
93
				public void onResponseReceived(Request request, Response response) {
-
 
94
					if (response.getText().length() != 0 && response.getText() != null) {
-
 
95
						final JSONValue responseValue = JSONParser.parse(response.getText());
-
 
96
						
-
 
97
						// Si la requête est un succès, reception d'un tableau
-
 
98
						if (responseValue.isString() != null) {
-
 
99
							GWT.log(responseValue.isString().stringValue(), null);
-
 
100
							Information info = new Information("suppression_structure", responseValue.isString().stringValue());
-
 
101
							info.setMessage("ok");
-
 
102
							r.rafraichir(info);
-
 
103
						} else {
-
 
104
							GWT.log(url+"\n\tLa réponse est une chaine valant null", null);
-
 
105
						}
-
 
106
					} else {
-
 
107
						GWT.log(url, null);
-
 
108
						if (response.getText().length() == 0) {
-
 
109
							GWT.log("\tLa réponse a une taille de 0", null);
-
 
110
						}
-
 
111
						if (response.getText() == null) {
-
 
112
							GWT.log("\tLa réponse vaul null", null);
-
 
113
						}
-
 
114
					}
-
 
115
				}
-
 
116
				
66
			}) ;
117
			}) ;
Line 67... Line 118...
67
		} catch (RequestException e) {
118
		} catch (RequestException e) {
68
			
119
			
69
		}
120
		}
70
	}
121
	}