1. #1
    Touch Premium Member
    Join Date
    Jan 2008
    Location
    Quebec, Canada
    Posts
    122
    Vote Rating
    1
    nbourdeau is on a distinguished road

      0  

    Exclamation 4.1 Beta 2 - Json reader and createAccessor

    4.1 Beta 2 - Json reader and createAccessor


    Hi,

    I'm trying to test my application in the Beta 2 and I have a question regarding the internals of the Json reader.

    Previously, I overrided the method "createAccessor" for custom needs. Now the method is still there but there is the new one "createFieldAccessExpression" which has the same documentation but seems to be called elsewhere.

    What is exactly the purpose of this new function and why not merge the two ?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Vote Rating
    828
    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


    It looks like createFieldAccessExpression is for mapping of fields to response fields.
    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
    Touch Premium Member
    Join Date
    Jan 2008
    Location
    Quebec, Canada
    Posts
    122
    Vote Rating
    1
    nbourdeau is on a distinguished road

      0  

    Default


    Ok I see ... now a function is builded as a string to extract data. Want I want is a "NullSafe" json extractor.
    For example, if mapping is user.description, I want to handle the fact that "user" can be null...

    I don't know how to achieve this in the new format ... my old custom function was doing something like this :
    Code:
                        var parts = expr.split('.');
                        return function(value) {
                            for (var i =0; i < parts.length; i++) {
                                if (!value)
                                    return null;
                                value = value[parts[i]];
                            }
                            return value;
                        };

  4. #4
    Sencha - Ext JS Dev Team dongryphon's Avatar
    Join Date
    Jul 2009
    Posts
    1,335
    Vote Rating
    130
    dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all

      0  

    Default


    Can you use a converter for the field?

    http://dev.sencha.com/deploy/ext-4.0...ld-cfg-convert
    Don Griffin
    Ext JS Development Team Lead

    Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue

    "Use the source, Luke!"

  5. #5
    Sencha - Ext JS Dev Team dongryphon's Avatar
    Join Date
    Jul 2009
    Posts
    1,335
    Vote Rating
    130
    dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all

      0  

    Default


    A converter, if it can achieve your goals, is much better than operating on the private methods behind the reader. Obviously, one has to do what one has to do...
    Don Griffin
    Ext JS Development Team Lead

    Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue

    "Use the source, Luke!"

  6. #6
    Ext JS Premium Member
    Join Date
    Jan 2008
    Posts
    25
    Vote Rating
    1
    lmalgras is on a distinguished road

      0  

    Default


    I've just had the same kind problem during my migration from 4.0.7 to 4.1.0

    Here is the convert function that I wrote to address this behaviour :
    Code:
        var jsonNullSafe = function(field, prop) {
            return function(v, record) {
                var json = record.get(field) || {},
                    value = json[prop];
                return value || v;
            }
        };
    
        Ext.define('Book', {
            extend: 'Ext.data.Model',
            fields: [{
                name: 'title'
            }, {
                name: 'author'
            }, {
                name: 'authorFirstName',
                convert: jsonNullSafe('author', 'fn')
            }, {
                name: 'authorLastName',
                convert: jsonNullSafe('author', 'ln')
            }]
        });
    In 4.0.7 my model was :
    Code:
        Ext.define('Book', {
            extend: 'Ext.data.Model',
            fields: [{
                name: 'title'
            }, {
                name: 'authorFirstName',
                mapping: 'author.fn'
            }, {
                name: 'authorLastName',
                mapping: 'author.ln'
            }]
        });

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