Re: Client side format string response to json array and display in jtextetable
> > problem resolved, error is due to bad json, i changed it and work, for testing my json array i'm gone https://jsonformatter.curiousconcept.com/ > . > -- You received this message because you are subscribed to the Google Groups "GWT Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscr...@googlegroups.com. To post to this group, send email to google-web-toolkit@googlegroups.com. Visit this group at https://groups.google.com/group/google-web-toolkit. For more options, visit https://groups.google.com/d/optout.
Client side format string response to json array and display in jtextetable
Hello everyone, can you help me please? I try from Client side format string response to json array and display in jtextetable. My class javascript object : package project.client; import com . google . gwt. core . client . JavaScriptObject ; import com . google . gwt. core . client . JsArray ; class Livre extends JavaScriptObject { protected Livre () {} public final native String getTitre () /*-{ return this.Titre; }-*/; public final native String getAuteurs () /*-{ return this.Auteur; }-*/; public final native static JsArray asArrayOfLivre ( String json ) /*-{ return eval ( json );; }-*/; } my response string formated res ="[\n"; while (rs.next()) { String id = rs.getString("id"); String titre = rs.getString("titre"); String auteur = rs.getString("auteur"); res += "\t{Id: \""+id+ "\",\n"; res += "\t{Auteur: \""+titre+ "\",\n"; res += "\t{Titre: \""+auteur+ "\",\n"; res += "\t},\n"; } res += "]\n"; And in client side : public void onSuccess(String result) { JsArray resultat = Livre.asArrayOfLivre ( result); for (int i = 0; i < resultat.length(); i++) { String Auteur = resultat.get(i).getAuteurs(); String titre = resultat.get(i).getTitre() ; taskContainer.setText(i+1,0,Auteur); taskContainer.setText(i+1,1,titre); } } }); I have no error but if I test one window.alert("test")after JsArray resultat = Livre.asArrayOfLivre ( result); it isn't executed so function don't executed? do you have idea for my problem? Thank you. -- You received this message because you are subscribed to the Google Groups "GWT Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscr...@googlegroups.com. To post to this group, send email to google-web-toolkit@googlegroups.com. Visit this group at https://groups.google.com/group/google-web-toolkit. For more options, visit https://groups.google.com/d/optout.
Re: How to use json in client side
thanks, finally i used a regex expression with split for get my string in client side, and i diplay witht flextable its more easy for me . -- You received this message because you are subscribed to the Google Groups "GWT Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscr...@googlegroups.com. To post to this group, send email to google-web-toolkit@googlegroups.com. Visit this group at https://groups.google.com/group/google-web-toolkit. For more options, visit https://groups.google.com/d/optout.
How to use json in client side
Hello everyone , can you help me please? in my server wich connect with mysql databse i send to my client one json table like that rs = stmt.executeQuery("SELECT * FROM test"); res ="["; while (rs.next()) { String titre = rs.getString("id"); String auteur = rs.getString("comment"); res += "\t{\"Titre\": \""+titre+ "\",\n"; res += "\t\"Auteur\": \""+auteur+ "\",\n"; res += "\t},\n"; } res += "]\n"; and after i try to receive and use json data but dont work in my client side final ProjectServiceAsync getService = GWT.create(ProjectService.class); getService.connection( new AsyncCallback() { public void onFailure(Throwable caught) { System.out.println("error"); } public void onSuccess(String result) { JSONValue jsonValue = JSONParser.parseStrict(result); com.google.gwt.json.client.JSONObject customerObject = jsonValue.isObject(); com.google.gwt.json.client.JSONArray jsonArray = customerObject.get("titre").isArray(); StringBuilder builder = new StringBuilder("** Livre ** \n"); builder.append(jsonArray.get(0).isObject().get("Titre").isString().stringValue()).append(" "); Window.alert(builder.toString()); //resultTxt.setText(result); } }); } if i use resultTxt.setText(result); i have my data but i want to writte table with line received. thanks for you helping sorry for my english -- You received this message because you are subscribed to the Google Groups "GWT Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscr...@googlegroups.com. To post to this group, send email to google-web-toolkit@googlegroups.com. Visit this group at https://groups.google.com/group/google-web-toolkit. For more options, visit https://groups.google.com/d/optout.