Subversion Repositories eFlore/Applications.coel

Compare Revisions

Ignore whitespace Rev 1048 → Rev 1049

/trunk/src/org/tela_botanica/client/modeles/commentaire/CommentaireAsyncDao.java
1,5 → 1,7
package org.tela_botanica.client.modeles.commentaire;
 
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,17 → 28,24
utilisateurId = ((Mediateur) Registry.get(RegistreId.MEDIATEUR)).getUtilisateurId();
}
 
public void selectionner(final String commentaireId, String projetId, String titre) {
public void selectionner(final String commentaireId, String projetId, String titre, final int pageCourante, final int nbElements) {
String[] parametres = {projetId, commentaireId, titre};
 
final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM, parametres);
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, parametres, restrictions);
rb.envoyerRequete(null, new JsonRestRequestCallback() {
@Override
public void surReponse(JSONValue responseValue) {
if (responseValue != null) {
// Si la requête est un succès, réception 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();
// Transformation du tableau JSON réponse en ListeInstitution
Commentaire commentaire = new Commentaire(reponse);
// et on met à jour le demandeur des données
42,7 → 52,15
vueARafraichir.rafraichir(commentaire);
} else if (responseValue.isArray() != null) {
final JSONArray reponse = responseValue.isArray();
CommentaireListe commentaires = new CommentaireListe(reponse);
CommentaireListe commentaires;
if (reponse.get(1).isObject() != null) {
commentaires = new CommentaireListe(reponse.get(1).isArray());
} else {
commentaires = new CommentaireListe(reponse.get(1).isArray(), reponse.get(0).isNumber(), vueARafraichir);
}
commentaires.setTaillePage(nbElements);
commentaires.setPageCourante(pageCourante);
 
vueARafraichir.rafraichir(commentaires);
} else {
GWT.log("La réponse n'est pas un objet ou un talbeau JSON et vaut : "+responseValue.toString(), null);