1. #1
    Ext User
    Join Date
    Apr 2007
    Location
    Eugene, OR
    Posts
    49
    Vote Rating
    0
    oregontarheel is on a distinguished road

      0  

    Question Send JSON back to server

    Send JSON back to server


    Hello all - I'm just getting started with Ext and I am very excited with some of the functionality! This may be a stupid question but I can't figure out how to send JSON-encoded objects back to the server. I want to manipulate javascript objects on the frontend that represent my Java beans on the backend, and I wish to just encode the object back to JSON (know how to do that), and then post it to the server, where it will be handled by my business logic. Right now I've got the data being loaded by a HttpProxy with a JsonReader. I want to be able to manipulate the data contained in my Ext.data.Store object and then encode it as JSON and pass back to a Java servlet... any advice? Just pointing me in the direction of a server send object would be a great help. I've got a good handle on asynchronous client/server communication, just can't figure out how to facilitate with Ext. Thanks in advance.

    Alex

  2. #2
    Ext User
    Join Date
    Apr 2007
    Posts
    18
    Vote Rating
    0
    tgo is on a distinguished road

      0  

    Default this may be of help ...

    this may be of help ...


    Hi,
    I have been struggling with this all afternoon, though on a Rails based application. My problem was to reflect the change I did in one cell of an EditorGrid and send it back to the server.
    It is not difficult but no too well documented at the moment (they are working on doc, I gather from other posts). So, the function below is my cell update callback. You are probably not interested in the function per se but in the usage of the connection object. The connection object is the only way I have found so far to handle post back to the server.

    Code:
    function upd(dataModel, record, sth) {
    	// so far, ignore COMMIT & REJECT calls
    	if (sth == Ext.data.Record.EDIT) {
    		var conn = new Ext.data.Connection();
    		conn.on('requestcomplete', function(dm,response,option) {
    			record.commit();
    		});
    		conn.on('requestexception', function(dm,response,option,e) {
    			Ext.MessageBox.alert('Error', 'Your changes could not be saved. The entry will be rolled back.');
    			record.reject();
    		});
    		conn.request( {
    			url: 'http://localhost:3000/authors/update',
    			method: "POST",
    			params: {
    					id: record.id,
    					author: Ext.util.JSON.encode(record.data)
    			}
    		});
    	}
    }

    If you look at conn.request, specifying the parameters in this way will send them encoded in JSON. Of course, in my case I have a neat record.data array but you see the idea ... I suppose there is no difference posting to Rails or a servlet.

    You may also be interested in the two callbacks to handle success or failure.

    I can only advise you to do as I did: delve in the code of Connection.js and friends.

    Hope this helps.

    --tgo

  3. #3
    Ext User
    Join Date
    Apr 2007
    Location
    Eugene, OR
    Posts
    49
    Vote Rating
    0
    oregontarheel is on a distinguished road

      0  

    Talking


    Thanks a bunch! That is exactly what I needed to get started! I had also looked into using YAHOO.util.Connect object, which is similar. Now that it's just Ext, is it bad practice to use yahoo ui classes in conjunction with Ext classes? Is that going to cause issues with either framework, or is it requiring extraneous js files to be downloaded? Just curious is all...

  4. #4
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    The Ext Connection class wraps the YUI Connect object, so you don't need to talk directly to YUI - it actually abstracts the connection functionality, so you can swap libraries to say jquery, and not have to change your connection code.

  5. #5
    Ext User
    Join Date
    Apr 2007
    Posts
    1
    Vote Rating
    0
    tol is on a distinguished road

      0  

    Default Sending UTF8 to server

    Sending UTF8 to server


    I have to send UTF8 (e.g.

Thread Participants: 3

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi