Rev 114 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package org.tela_botanica.client.modeles;import org.tela_botanica.client.RegistreId;import org.tela_botanica.client.interfaces.Rafraichissable;import com.extjs.gxt.ui.client.Registry;import com.google.gwt.http.client.Request;import com.google.gwt.http.client.RequestBuilder;import com.google.gwt.http.client.RequestCallback;import com.google.gwt.http.client.RequestException;import com.google.gwt.http.client.Response;import com.google.gwt.json.client.JSONArray;import com.google.gwt.json.client.JSONParser;import com.google.gwt.json.client.JSONValue;import com.google.gwt.user.client.Window;public class PublicationListeAsyncDao {private PublicationListe publications = null;private Rafraichissable rafraichissement = null;public PublicationListeAsyncDao(Rafraichissable r) {rafraichissement = r ;}public void obtenirListePublication() {// Demande de toutes les structuresString url = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl();RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, url+"CoelPublicationListe/");try {rb.sendRequest(null, new RequestCallback() {public void onError(Request request, Throwable exception) {// TODO Auto-generated method stub}public void onResponseReceived(Request request, Response response) {final JSONValue responseValue = JSONParser.parse(response.getText());// Si la requête est un succès, reception d'un tableauif (responseValue.isArray() != null) {final JSONArray reponse = responseValue.isArray();// Transformation du tableau JSON réponse en ListeInstitutionpublications = new PublicationListe(reponse);// et on met à jour le demandeur des donnéesrafraichissement.rafraichir(publications);}else{publications = new PublicationListe(0);rafraichissement.rafraichir(publications);}}});} catch (RequestException e) {e.printStackTrace();}}}