1. #1
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Mumbai, India
    Posts
    191
    Answers
    10
    Vote Rating
    0
    bomslang has a little shameless behaviour in the past

      0  

    Exclamation Unanswered: Cannot read property "fields" of undefined

    Unanswered: Cannot read property "fields" of undefined


    Folks,

    I am trying to bind my model with store using REST proxy as shown here

    http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.Model

    Here's my code inside launch( ) function :-

    Code:
    launch: function() {
            
            Ext.define('Record', {
                extend: 'Ext.data.Model',
                fields: [{name: 'id', type:'int'}, {name:'content', type:'string'} ,{name: 'name', type:'string'} ,{name:'title', type:'string'}],
          proxy: {
                  type: 'rest',
                  api: {
                    read : 'feedback/read.action',
                     create : 'feedback/new.action',
                        update: 'feedback/update.action',
                        destroy: 'feedback/delete.action'
                    },
                    reader: {
                        type: 'json',
                        root: 'data',
                        totalProperty: 'total',
                        successProperty: 'success',
                        idProperty: 'id'
                    },
                    writer: {
                        type: 'json',
                        encode: true,
                        writeAllFields: true
                    }
                }
            });
            
    var record = Ext.create('Record', {content:'ABC', name: 'XYZ', title: 'Title Text'});
    var store = new Ext.data.Store({
                model: record,
                autoSave: false,
                autoLoad: true
    });
    But it throws me below errors saying
    Code:
    Uncaught TypeError: Cannot read property 'fields' of undefined
    error.jpg
    --
    Bomslang,
    Software Engineer,
    HTML5 Developer | ExtJS, Sencha Touch, GXT Passionate | Json Supporter

    Twitter : @bomslang

    ----------------------------------------------------------------------------------

    # Learn about Sencha Products via it's Documentation : ExtJS | Sencha Touch | GXT

    # Check for correct Json here : JSONLint.com

    # Want to code Sencha Touch Online ? Try SenchaFiddle.com

    # Want to code and test ExtJS Online ? Try http://ext4all.com/ & http://jsfiddle.net/

    # Must Read : 20 things to avoid / do when starting with ExtJS or Sencha Touch

  2. #2
    jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,353
    Answers
    102
    Vote Rating
    79
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    Model needs to be the Namespace of a constructor OR a reference to the constructor itself!

    replace
    model: record,
    with
    model: 'Record'

  3. #3
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Mumbai, India
    Posts
    191
    Answers
    10
    Vote Rating
    0
    bomslang has a little shameless behaviour in the past

      0  

    Default


    Thanks Jay.

    That was helpful.

    But minor problem I am facing is that -

    I can now see the form values being appeared on grid panel. But those values aren't persisted in the database. I can't see them in DB.

    It also throws me below exception ;-
    Code:
    POST http://localhost:8080/app/feedback/new.action?_dc=1346784472834 415 (Unsupported Media Type)

    FYI, This is my server side code
    Code:
    @RequestMapping(value="/new.action", method=RequestMethod.POST)
        public @ResponseBody Map<String,? extends Object> create(@RequestBody Object data) throws Exception {
      try{
         List<Feedback> feedbacks = feedbackService.create(data);
         return getMap(feedbacks);
    } catch (Exception e) {
           return getModelMapError("Error trying to create Feedback.");
     }
    }
    Why is this happening ?
    --
    Bomslang,
    Software Engineer,
    HTML5 Developer | ExtJS, Sencha Touch, GXT Passionate | Json Supporter

    Twitter : @bomslang

    ----------------------------------------------------------------------------------

    # Learn about Sencha Products via it's Documentation : ExtJS | Sencha Touch | GXT

    # Check for correct Json here : JSONLint.com

    # Want to code Sencha Touch Online ? Try SenchaFiddle.com

    # Want to code and test ExtJS Online ? Try http://ext4all.com/ & http://jsfiddle.net/

    # Must Read : 20 things to avoid / do when starting with ExtJS or Sencha Touch

  4. #4
    jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,353
    Answers
    102
    Vote Rating
    79
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    Dude. You're back to where you have been for over a week!

    Bring things down to simple terms. Make a simple form, submit it via POST. do you get the same error!?

    your server side code is not correct.

  5. #5
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Mumbai, India
    Posts
    191
    Answers
    10
    Vote Rating
    0
    bomslang has a little shameless behaviour in the past

      0  

    Default


    I checked with this simple HTML form POST for that REST url.

    It throws me below error on chrome window
    Code:
    Type Status report
    message Request method 'POST' not supported
    description The specified HTTP method is not allowed for the requested resource (Request method 'POST' not supported).
    Should I try it by setting it to RequestMethod.PUT on server side ?
    --
    Bomslang,
    Software Engineer,
    HTML5 Developer | ExtJS, Sencha Touch, GXT Passionate | Json Supporter

    Twitter : @bomslang

    ----------------------------------------------------------------------------------

    # Learn about Sencha Products via it's Documentation : ExtJS | Sencha Touch | GXT

    # Check for correct Json here : JSONLint.com

    # Want to code Sencha Touch Online ? Try SenchaFiddle.com

    # Want to code and test ExtJS Online ? Try http://ext4all.com/ & http://jsfiddle.net/

    # Must Read : 20 things to avoid / do when starting with ExtJS or Sencha Touch

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