1,5 → 1,7 |
package org.tela_botanica.client.modeles.projet; |
|
import java.util.HashMap; |
|
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.RegistreId; |
import org.tela_botanica.client.http.JsonRestRequestBuilder; |
6,6 → 8,7 |
import org.tela_botanica.client.http.JsonRestRequestCallback; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.Information; |
import org.tela_botanica.client.modeles.structure.StructureListe; |
import org.tela_botanica.client.util.UtilDAO; |
|
import com.extjs.gxt.ui.client.Registry; |
25,24 → 28,40 |
utilisateurId = ((Mediateur) Registry.get(RegistreId.MEDIATEUR)).getUtilisateurId(); |
} |
|
public void selectionner(final String projetId) { |
String[] param = {projetId}; |
final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM, param); |
public void selectionner(final String projetId, final String nom, final int pageCourante, final int nbElements) { |
String[] param = {projetId, nom}; |
|
HashMap<String, String> restrictions = new HashMap<String, String>(); |
restrictions.put("start", String.valueOf(pageCourante)); |
if (nbElements != -1) { |
restrictions.put("limit", String.valueOf(nbElements)); |
} |
|
final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM, param, restrictions); |
rb.envoyerRequete(null, new JsonRestRequestCallback() { |
@Override |
public void surReponse(JSONValue responseValue) { |
if (responseValue != null) { |
// Si la requête est un succès, reception d'un objet ou d'un tableau |
if (responseValue.isObject() != null) { |
final JSONObject reponse = responseValue.isObject(); |
JSONArray responseArray = responseValue.isArray(); |
if (responseArray.get(1).isObject() != null) { |
final JSONObject reponse = responseArray.get(1).isObject(); |
Projet projet = new Projet(reponse); |
|
Information info = new Information("selection_projet"); |
info.setDonnee(0, projet); |
vueARafraichir.rafraichir(info); |
} else if (responseValue.isArray() != null) { |
} else if (responseArray.get(1).isArray() != null) { |
final JSONArray reponse = responseValue.isArray(); |
ProjetListe projets = new ProjetListe(reponse); |
ProjetListe projets; |
if (responseArray.get(1).isObject() != null) { |
projets = new ProjetListe(reponse.get(1).isArray()); |
} else { |
projets = new ProjetListe(reponse.get(1).isArray(), reponse.get(0).isNumber(), vueARafraichir); |
} |
projets.setTaillePage(nbElements); |
projets.setPageCourante(pageCourante); |
|
vueARafraichir.rafraichir(projets); |
} else { |
GWT.log(rb.getUrl()+"\n\tLa réponse n'est pas un objet ou un talbeau JSON et vaut : "+responseValue.toString(), null); |