Hybrid View

  1. #1
    Sencha User aflx's Avatar
    Join Date
    Jun 2011
    Location
    Berlin, Germany
    Posts
    64
    Vote Rating
    0
    aflx is on a distinguished road

      0  

    Default Custom proxy with B1

    Custom proxy with B1


    Hi,

    I'm trying to implement my own proxy. But I have some problems now.
    Everytime my create function is called, everything works well (data gets saved). But the operations are saved too! This means, that the create operation is still there and every following record to create is saved to this operation and gets recreated during the next call. After a few cycles, I have several records in the create operation of the batch.

    My create function looks like this:

    Code:
    create: function(operation, callback, scope) {
        if (!this._dbInitialized) {
            this.initDataBase();
        }
    
        var me = this;
    
        var records = operation.getRecords(),
            length = records.length,
            record,
            i;
    
        operation.setStarted();
    
        for (i = 0; i < length; i++) {
            record = records[i];
            me.setRecord(record);
        }
    
        operation.setCompleted();
        operation.setSuccessful();
    
        if (typeof callback == 'function') {
            callback.call(scope || me, operation);
        }
    },
    So the problem is now, that the created records are still present in the create batch/operation.
    I found the following in the Ext.data.Store:

    Code:
    ...
    // These methods are now just template methods since updating the records etc is all taken care of
    // by the operation itself.
    onCreateRecords: function(records, operation, success) {},
    onUpdateRecords: function(records, operation, success) {},
    ...
    These functions are called in onProxyWrite().
    Do I have to override these functions and remove the records by hand? Or what else do I have to do?

    At the moment it is very hard to write a custom proxy for ST2. Do you think, you can write some docu for this?

    Thx,
    Alex

    UPDATE:

    Ok, I think the problem is in the sync() function, where getNewRecords() is called, which filters records by the phantom flag:

    Code:
    sync: function() {
        var me = this,
            operations = {},
            toCreate = me.getNewRecords(),
    ...
    I saw in the debugger, that the added records have still the phantom flag set to true.
    Do I have to set this to false by hand? Where? Directly after I saved the record (me.setRecord()) or where is the best location for this?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,801
    Vote Rating
    834
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    In your for loop, try record.phantom = false.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User aflx's Avatar
    Join Date
    Jun 2011
    Location
    Berlin, Germany
    Posts
    64
    Vote Rating
    0
    aflx is on a distinguished road

      0  

    Default


    Thx! That is working.

    Are there any plans to make a tutorial for this? What are the requirements for building a custom proxy... What are the operations and their properties good for (records vs. resultSet...). How does a proxy/store work in detail.

    Maybe this is interesting for other too?

    Best regards

    Alex

  4. #4
    Sencha User
    Join Date
    Mar 2007
    Location
    Haarlem, Netherlands
    Posts
    1,243
    Vote Rating
    10
    TommyMaintz will become famous soon enough TommyMaintz will become famous soon enough

      0  

    Default


    Hi aflx,

    I will try to write some documentation on how to implement your own custom proxies. For now could you maybe post your custom proxy in full? I could take a look at it and see what I would change and add comments as to why.

    Thanks

  5. #5
    Sencha User aflx's Avatar
    Join Date
    Jun 2011
    Location
    Berlin, Germany
    Posts
    64
    Vote Rating
    0
    aflx is on a distinguished road

      0  

    Default


    Hey Tommy!
    I saw, that there is already another SqliteProxy mentioned in the forum: https://github.com/tomalex0/SenchaTouch-v2-SqliteProxy

    Maybe it is a good idea to help the author? It would be a great example too

    Bye,
    Alex

  6. #6
    Sencha User
    Join Date
    Oct 2011
    Location
    Pakistan
    Posts
    229
    Vote Rating
    1
    umr.ashrf is on a distinguished road

      0  

    Default


    Your proxy looks great to me. When I was writing a Proxy I found no tutorial for it and what I did was grab the source code of already written proxies and modify them according to what I want.

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