New file |
0,0 → 1,66 |
package org.tela_botanica.client.modeles; |
|
import org.tela_botanica.client.image.ImageMediateur; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
|
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONObject; |
import com.google.gwt.json.client.JSONParser; |
import com.google.gwt.json.client.JSONString; |
import com.google.gwt.json.client.JSONValue; |
import com.google.gwt.user.client.HTTPRequest; |
import com.google.gwt.user.client.ResponseTextHandler; |
import com.google.gwt.user.client.Window; |
|
public class NombreImageAsynchroneDAO { |
|
private ImageMediateur iMediateur = null ; |
|
public void setImediateur(ImageMediateur im) |
{ |
iMediateur = im ; |
} |
|
public void obtenirNombreImages(final Rafraichissable r, String[][] criteres) |
{ |
String requete = "" ; |
|
if(criteres != null) |
{ |
for (int i = 0; i < criteres.length; i++) { |
|
if(!criteres[i][0].equals("ci_ordre")) |
{ |
if(i != 0) |
{ |
requete += "&" ; |
} |
requete += criteres[i][0]+"="+criteres[i][1] ; |
if(i != criteres.length - 1) |
{ |
requete += "&" ; |
} |
} |
} |
} |
|
HTTPRequest.asyncGet("jrest/InventoryImageCount/0/"+requete, new ResponseTextHandler() { |
public void onCompletion(String responseText) { |
|
final JSONValue responseValue = JSONParser.parse(responseText); |
|
if(responseValue.isArray() != null) |
{ |
JSONValue res = responseValue.isArray().get(0) ; |
JSONString reponseNombre = res.isString() ; |
int maxImages = (int)Integer.parseInt(reponseNombre.stringValue()) ; |
int[] nbImages = {maxImages} ; |
r.rafraichir(nbImages, true) ; |
} |
|
} |
|
}) ; |
} |
|
} |