IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

GWT et Vaadin Java Discussion :

GWT et Json complexe


Sujet :

GWT et Vaadin Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Inscrit en
    Août 2011
    Messages
    22
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations forums :
    Inscription : Août 2011
    Messages : 22
    Par défaut GWT et Json complexe
    bonjour, je n'arrives pas à parser mon flux json en objet

    mon json :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    [{
      "products_id": "223",
      "products_name": "tuto",
      "products_description": "",
      "products_model": "tutu",
      "products_image": "http://...200.jpg",
      "products_price": "999",
      "products_devise": "€",
      "products_remise": 0,
      "products_price_remise": "999",
      "attibuts": [{
        "id": "2541",
        "text": "Candy",
        "description": "toto",
        "prefix" : "+",
        "price" : "8"
      }]
    mon produit
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
     
    package.....client.entity;
     
    import com.google.gwt.core.client.JavaScriptObject;
    import com.google.gwt.core.client.JsArray;
     
    public class Produit extends JavaScriptObject {
     
    	protected Produit() {}                                              
     
    	// JSNI methods to get stock data.
    	public final native String getSymbol() 					/*-{ return this.symbol; 				}-*/; 
    	public final native String getProducts_id() 			/*-{ return this.products_id; 			}-*/;
    	public final native String getProducts_name() 			/*-{ return this.products_name; 		}-*/;
    	public final native String getProducts_description()	/*-{ return this.products_description; 	}-*/;
    	public final native String getProducts_model() 			/*-{ return this.products_model; 		}-*/;
    	public final native String getProducts_image() 			/*-{ return this.products_image; 		}-*/;
    	public final native String getProducts_price() 			/*-{ return this.products_price;	 	}-*/;
    	public final native String getProducts_devise() 		/*-{ return this.products_devise; 		}-*/;
    	public final native String getproducts_price_remise() 	/*-{ return this.products_price_remise; }-*/;
    	public final native int getproducts_remise() 			/*-{ return this.products_remise; 		}-*/;
    	public final native JsArray<Attribut> getAttributs() 	/*-{ return this.attibuts; 				}-*/;	
    }
    et mon attribut :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    import com.google.gwt.core.client.JavaScriptObject;
     
    public class Attribut extends JavaScriptObject {
     
    	protected Attribut() {}                                              
     
    	// JSNI methods to get stock data.
    	public final native String getId() 					/*-{ return this.id; }-*/; 
    	public final native String getText() 				/*-{ return this.text; }-*/; 
    	public final native String getDescription()  		/*-{ return this.description; }-*/;
    	public final native String getPrefix()  			/*-{ return this.prefix; }-*/;
    	public final native String getPrice()  				/*-{ return this.price; }-*/;
    }
    Dans l'Entry point j'utilise ;
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    private final native JsArray<Produit> asArrayOfStockData(String json) /*-{
        return eval(json);
      }-*/;
    j'y arrive tres bien, tant que je ne mets pas la partie attribut. Apres ca plante
    Je dois mal mapper le deuxieme objet ?
    Avez vous une idée ?
    Merci

  2. #2
    Membre averti
    Homme Profil pro
    Inscrit en
    Août 2011
    Messages
    22
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations forums :
    Inscription : Août 2011
    Messages : 22
    Par défaut
    Désolé, il manquait : }]

    Mais bon, ca fait un exemple en ligne

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Dojo] Afficher un objet json complexe dans un datagrid ?
    Par andlio dans le forum Bibliothèques & Frameworks
    Réponses: 1
    Dernier message: 03/01/2012, 19h35
  2. Peut-on envoyer un objet Json complexe au serveur ?
    Par drooss dans le forum jQuery
    Réponses: 9
    Dernier message: 13/07/2011, 15h51
  3. GWT + variable JSon
    Par Angi21 dans le forum GWT et Vaadin
    Réponses: 0
    Dernier message: 06/06/2011, 00h53
  4. PHP5 GWT et JSON
    Par aziz_salut dans le forum GWT et Vaadin
    Réponses: 4
    Dernier message: 05/08/2010, 18h43
  5. gwt /html /json
    Par aminebk dans le forum Général JavaScript
    Réponses: 0
    Dernier message: 13/07/2010, 12h47

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo