Monday, April 23, 2012

JQuery: parse json text to json Object


var obj = jQuery.parseJSON('{"name":"John"}');
alert( obj.name === "John" );


Reference:
http://api.jquery.com/jQuery.parseJSON/

GSON: map to json string simple example


import com.google.gson.Gson;
...
...
Map<String,Object> modelMap = new HashMap<String,Object>();
modelMap.put("message", "welcome");
modelMap.put("success", false);
modelMap.put("data", new Object());                                    


Gson gson = new Gson();
String jsonOutput = gson.toJson(modelMap); // {"message":"welcome","data":{},"success":false}


Resources:
http://blog.pontt.com/json-con-java/introduccion-java-y-json-primera-parte-con-ejemplo/
http://code.google.com/p/google-gson/

Friday, April 20, 2012

ExtJS4: get values from ExtJS form

Use the form.getValues() Method:

var  myFormPanelObj  = Ext.getCmp("myFormPanelId");
var data  =   myFormPanelObj.getForm().getValues();  
console.log("data: " + Ext.JSON.encode(data)); // {field1name : "field1value" , field2name : "field2value"}

References:
http://www.sencha.com/forum/showthread.php?62958-ExtJs-Jquery-form-submit

Thursday, April 19, 2012

Spring 3.0 - Ajax Handling Example

Finally I found a Simple and Fully functional sample of a proyect ussing the spring framework and the Ajax Technology. It's a Netbeans Project. There is the explained code and you can download the project sources.

http://cmop17.wordpress.com/2010/12/17/spring-usando-ajax-con-jquery-post-and-get/