1. #11
    Sencha User
    Join Date
    Oct 2010
    Location
    Argentina
    Posts
    1
    Vote Rating
    0
    photon is on a distinguished road

      0  

    Default


    Sorry by my English

    First, it happen since 4.2 that introduce the utility class Ext.container.Monitor.


    I think found the problem.


    The error "this.monitor is null" , appear when submit the form and immediately in next instruction destroys the container form.


    It happen because the submit action is asynchronous then if the container was destroy before the action submit call this.monitor, it appear null !!.


    Solution: be sure not destroy container's form before the submit action end or defer it enough. (100 mil. sec. work for me) until not get this error.


    work example :

    Code:
     
    var fp = Ext.create('Ext.form.Panel',{
                                     url: "/data/form",
    
                                     standardSubmit:true,
                                     baseParams: {'param1': 'test'}
                  });
        fp.getForm().submit();
    //if not defer get this.monitor null error
    Ext.defer(fp.destroy, 100, fp);

  2. #12
    Sencha Premium Member
    Join Date
    Mar 2011
    Location
    McKinney, TX
    Posts
    40
    Vote Rating
    0
    jbender11 is on a distinguished road

      0  

    Default this.monitor is null with Architect app

    this.monitor is null with Architect app


    I too was seeing this bug after switching from Ext-js 4.1.1 to 4.2.1.883. I'm using Architect 2.2.0 to generate code.

    My form works great in 4.1.1. Just switching to 4.2.1 exposes the problem. It does have something to do with closing the view too early. Here's my code:

    Code:
    var form = button.up('form').getForm();
    var params = form.getValues(true,true,false,false);
    var url = button.buildURL(params);
    if (form.isValid()) {
        form.submit({
            url: url,
            params: params,
            waitMsg: 'Uploading your file...',
            timeout: 30,
            method: 'POST',
            success: function(form, action) {
                Ext.Msg.alert('Success', 'New invoice has been sent for approval.');
            },
            failure: function(form, action) {
                var responseText = action.response.responseText;
                var jsonResp = JSON.parse(responseText); 
                var reason = jsonResp.reason;
    
                Ext.Msg.alert('Failed', reason);
            }
        });
    }
    
    this.hide();
    Note that in 4.1.1, I was hiding the singleton window that contained the form as soon as the submit() was executed.

    The actual error seen in firebug was at line 89218 of ext-all-debug.js
    Code:
     
    getFields: function() {
            return this.monitor.getItems();
        },
    The workaround (thanks to photon's insight) is to not hide the container until after a successful submit like this:

    Code:
    var form = button.up('form').getForm();
    var params = form.getValues(true,true,false,false);
    var url = button.buildURL(params);
    if (form.isValid()) {
        form.submit({
            url: url,
            params: params,
            waitMsg: 'Uploading your file...',
            timeout: 30,
            method: 'POST',
            success: function(form, action) {
                Ext.Msg.alert('Success', 'New invoice has been sent for approval.');
                this.hide();
            },
            failure: function(form, action) {
                var responseText = action.response.responseText;
                var jsonResp = JSON.parse(responseText); 
                var reason = jsonResp.reason;
    
                Ext.Msg.alert('Failed', reason);
            }
        });
    }
    But in my humble opinion, this is a bug that has crept into 4.2 :-(

  3. #13
    Sencha User
    Join Date
    Jun 2013
    Location
    china
    Posts
    7
    Vote Rating
    -3
    ZhengYueChuan can only hope to improve

      0  

    Default


    you can set window closeAction:'hide'

  4. #14
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,050
    Vote Rating
    657
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Someone posted a similar problem but I wasn't able to reproduce it. Would it be possible to post a standalone test case?
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  5. #15
    Sencha Premium Member
    Join Date
    Mar 2011
    Location
    McKinney, TX
    Posts
    40
    Vote Rating
    0
    jbender11 is on a distinguished road

      0  

    Default Sample app

    Sample app


    Well, I spent an hour or so trying to put together a sample that shows the problem and of course the sample didn't have any problems at all. So apparently it is something a bit more subtle. It could be a timing issue or the fact that I upgraded the Architect app from a 4.1.1 runtime to a 4.2 runtime. The sample app was created initially as a 4.2 app in Architect so it didn't go through the upgrade process. Not really sure if that has anything to do with it at all.

    I will spend some more time trying to recreate a simple app this weekend. But if I can't, I may have to include my entire rather large app.

    John

  6. #16
    Sencha Premium Member
    Join Date
    Apr 2013
    Location
    Bratislava, Slovakia
    Posts
    12
    Vote Rating
    0
    movys is on a distinguished road

      0  

    Default


    I can confirm this error is due to prematurely closing the form panel. Upon submitting the form, either hide it (don't destroy it), or even better, destroy it in the success callback (this way you will be able to display potential validation errors from the server:


    Pseudocode in your form controller:
    Code:
    // ... when submitting the form
    var form; // get the reference to the form somehow - see the docs on your options
    form.submit({
        url: '/your/url/here',
        success: function() {
            form.up('window').close(); // this closes the window in which the form sits
        }
    });